diff --git a/src/Symfony/Bridge/Doctrine/Tests/Security/User/EntityUserProviderTest.php b/src/Symfony/Bridge/Doctrine/Tests/Security/User/EntityUserProviderTest.php
index 59793406b5..775e223a74 100644
--- a/src/Symfony/Bridge/Doctrine/Tests/Security/User/EntityUserProviderTest.php
+++ b/src/Symfony/Bridge/Doctrine/Tests/Security/User/EntityUserProviderTest.php
@@ -21,6 +21,7 @@ use Symfony\Bridge\Doctrine\Security\User\UserLoaderInterface;
use Symfony\Bridge\Doctrine\Test\DoctrineTestHelper;
use Symfony\Bridge\Doctrine\Tests\Fixtures\User;
use Symfony\Component\Security\Core\User\PasswordUpgraderInterface;
+use Symfony\Component\Security\Core\User\UserInterface;
class EntityUserProviderTest extends TestCase
{
@@ -154,7 +155,7 @@ class EntityUserProviderTest extends TestCase
->method('loadUserByUsername')
->with('name')
->willReturn(
- $this->getMockBuilder('\Symfony\Component\Security\Core\User\UserInterface')->getMock()
+ $this->getMockBuilder(UserInterface::class)->getMock()
);
$provider = new EntityUserProvider(
diff --git a/src/Symfony/Bridge/ProxyManager/Tests/LazyProxy/ContainerBuilderTest.php b/src/Symfony/Bridge/ProxyManager/Tests/LazyProxy/ContainerBuilderTest.php
index fc5af78fac..69b7239655 100644
--- a/src/Symfony/Bridge/ProxyManager/Tests/LazyProxy/ContainerBuilderTest.php
+++ b/src/Symfony/Bridge/ProxyManager/Tests/LazyProxy/ContainerBuilderTest.php
@@ -14,6 +14,8 @@ namespace Symfony\Bridge\ProxyManager\Tests\LazyProxy;
require_once __DIR__.'/Fixtures/includes/foo.php';
use PHPUnit\Framework\TestCase;
+use ProxyManager\Proxy\LazyLoadingInterface;
+use ProxyManagerBridgeFooClass;
use Symfony\Bridge\ProxyManager\LazyProxy\Instantiator\RuntimeInstantiator;
use Symfony\Component\DependencyInjection\ContainerBuilder;
@@ -31,7 +33,7 @@ class ContainerBuilderTest extends TestCase
$builder->setProxyInstantiator(new RuntimeInstantiator());
- $builder->register('foo1', 'ProxyManagerBridgeFooClass')->setFile(__DIR__.'/Fixtures/includes/foo.php')->setPublic(true);
+ $builder->register('foo1', ProxyManagerBridgeFooClass::class)->setFile(__DIR__.'/Fixtures/includes/foo.php')->setPublic(true);
$builder->getDefinition('foo1')->setLazy(true);
$builder->compile();
@@ -43,16 +45,16 @@ class ContainerBuilderTest extends TestCase
$this->assertSame(0, $foo1::$destructorCount);
$this->assertSame($foo1, $builder->get('foo1'), 'The same proxy is retrieved on multiple subsequent calls');
- $this->assertInstanceOf('\ProxyManagerBridgeFooClass', $foo1);
- $this->assertInstanceOf('\ProxyManager\Proxy\LazyLoadingInterface', $foo1);
+ $this->assertInstanceOf(ProxyManagerBridgeFooClass::class, $foo1);
+ $this->assertInstanceOf(LazyLoadingInterface::class, $foo1);
$this->assertFalse($foo1->isProxyInitialized());
$foo1->initializeProxy();
$this->assertSame($foo1, $builder->get('foo1'), 'The same proxy is retrieved after initialization');
$this->assertTrue($foo1->isProxyInitialized());
- $this->assertInstanceOf('\ProxyManagerBridgeFooClass', $foo1->getWrappedValueHolderValue());
- $this->assertNotInstanceOf('\ProxyManager\Proxy\LazyLoadingInterface', $foo1->getWrappedValueHolderValue());
+ $this->assertInstanceOf(ProxyManagerBridgeFooClass::class, $foo1->getWrappedValueHolderValue());
+ $this->assertNotInstanceOf(LazyLoadingInterface::class, $foo1->getWrappedValueHolderValue());
$foo1->__destruct();
$this->assertSame(1, $foo1::$destructorCount);
diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Controller/ControllerNameParserTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Controller/ControllerNameParserTest.php
index f8eccbb75e..35580abaad 100644
--- a/src/Symfony/Bundle/FrameworkBundle/Tests/Controller/ControllerNameParserTest.php
+++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Controller/ControllerNameParserTest.php
@@ -51,7 +51,7 @@ class ControllerNameParserTest extends TestCase
$parser->parse('foo:');
$this->fail('->parse() throws an \InvalidArgumentException if the controller is not an a:b:c string');
} catch (\Exception $e) {
- $this->assertInstanceOf('\InvalidArgumentException', $e, '->parse() throws an \InvalidArgumentException if the controller is not an a:b:c string');
+ $this->assertInstanceOf(\InvalidArgumentException::class, $e, '->parse() throws an \InvalidArgumentException if the controller is not an a:b:c string');
}
}
@@ -66,21 +66,21 @@ class ControllerNameParserTest extends TestCase
$parser->build('TestBundle\FooBundle\Controller\DefaultController::index');
$this->fail('->parse() throws an \InvalidArgumentException if the controller is not an aController::cAction string');
} catch (\Exception $e) {
- $this->assertInstanceOf('\InvalidArgumentException', $e, '->parse() throws an \InvalidArgumentException if the controller is not an aController::cAction string');
+ $this->assertInstanceOf(\InvalidArgumentException::class, $e, '->parse() throws an \InvalidArgumentException if the controller is not an aController::cAction string');
}
try {
$parser->build('TestBundle\FooBundle\Controller\Default::indexAction');
$this->fail('->parse() throws an \InvalidArgumentException if the controller is not an aController::cAction string');
} catch (\Exception $e) {
- $this->assertInstanceOf('\InvalidArgumentException', $e, '->parse() throws an \InvalidArgumentException if the controller is not an aController::cAction string');
+ $this->assertInstanceOf(\InvalidArgumentException::class, $e, '->parse() throws an \InvalidArgumentException if the controller is not an aController::cAction string');
}
try {
$parser->build('Foo\Controller\DefaultController::indexAction');
$this->fail('->parse() throws an \InvalidArgumentException if the controller is not an aController::cAction string');
} catch (\Exception $e) {
- $this->assertInstanceOf('\InvalidArgumentException', $e, '->parse() throws an \InvalidArgumentException if the controller is not an aController::cAction string');
+ $this->assertInstanceOf(\InvalidArgumentException::class, $e, '->parse() throws an \InvalidArgumentException if the controller is not an aController::cAction string');
}
}
@@ -95,7 +95,7 @@ class ControllerNameParserTest extends TestCase
$parser->parse($name);
$this->fail('->parse() throws a \InvalidArgumentException if the class is found but does not exist');
} catch (\Exception $e) {
- $this->assertInstanceOf('\InvalidArgumentException', $e, '->parse() throws a \InvalidArgumentException if the class is found but does not exist');
+ $this->assertInstanceOf(\InvalidArgumentException::class, $e, '->parse() throws a \InvalidArgumentException if the class is found but does not exist');
}
}
@@ -125,7 +125,7 @@ class ControllerNameParserTest extends TestCase
$parser->parse($bundleName);
$this->fail('->parse() throws a \InvalidArgumentException if the bundle does not exist');
} catch (\Exception $e) {
- $this->assertInstanceOf('\InvalidArgumentException', $e, '->parse() throws a \InvalidArgumentException if the bundle does not exist');
+ $this->assertInstanceOf(\InvalidArgumentException::class, $e, '->parse() throws a \InvalidArgumentException if the bundle does not exist');
if (false === $suggestedBundleName) {
// make sure we don't have a suggestion
diff --git a/src/Symfony/Bundle/FrameworkBundle/Tests/Translation/TranslatorTest.php b/src/Symfony/Bundle/FrameworkBundle/Tests/Translation/TranslatorTest.php
index 4cad213319..db0e6dc5d3 100644
--- a/src/Symfony/Bundle/FrameworkBundle/Tests/Translation/TranslatorTest.php
+++ b/src/Symfony/Bundle/FrameworkBundle/Tests/Translation/TranslatorTest.php
@@ -140,7 +140,7 @@ class TranslatorTest extends TestCase
$this->expectException('InvalidArgumentException');
$this->expectExceptionMessage('Invalid "invalid locale" locale.');
$loader = $this->getMockBuilder('Symfony\Component\Translation\Loader\LoaderInterface')->getMock();
- $translator = $this->getTranslator($loader, ['cache_dir' => $this->tmpDir], 'loader', '\Symfony\Bundle\FrameworkBundle\Tests\Translation\TranslatorWithInvalidLocale');
+ $translator = $this->getTranslator($loader, ['cache_dir' => $this->tmpDir], 'loader', TranslatorWithInvalidLocale::class);
$translator->trans('foo');
}
@@ -346,7 +346,7 @@ class TranslatorTest extends TestCase
return $container;
}
- public function getTranslator($loader, $options = [], $loaderFomat = 'loader', $translatorClass = '\Symfony\Bundle\FrameworkBundle\Translation\Translator', $defaultLocale = 'en')
+ public function getTranslator($loader, $options = [], $loaderFomat = 'loader', $translatorClass = Translator::class, $defaultLocale = 'en')
{
$translator = $this->createTranslator($loader, $options, $translatorClass, $loaderFomat, $defaultLocale);
@@ -403,7 +403,7 @@ class TranslatorTest extends TestCase
$this->assertEquals('It works!', $translator->trans('message', [], 'domain.with.dots'));
}
- private function createTranslator($loader, $options, $translatorClass = '\Symfony\Bundle\FrameworkBundle\Translation\Translator', $loaderFomat = 'loader', $defaultLocale = 'en')
+ private function createTranslator($loader, $options, $translatorClass = Translator::class, $loaderFomat = 'loader', $defaultLocale = 'en')
{
if (null === $defaultLocale) {
return new $translatorClass(
diff --git a/src/Symfony/Bundle/SecurityBundle/Tests/Functional/UserPasswordEncoderCommandTest.php b/src/Symfony/Bundle/SecurityBundle/Tests/Functional/UserPasswordEncoderCommandTest.php
index f4cb1c72ba..b6245286a8 100644
--- a/src/Symfony/Bundle/SecurityBundle/Tests/Functional/UserPasswordEncoderCommandTest.php
+++ b/src/Symfony/Bundle/SecurityBundle/Tests/Functional/UserPasswordEncoderCommandTest.php
@@ -258,7 +258,7 @@ class UserPasswordEncoderCommandTest extends AbstractWebTestCase
public function testEncodePasswordNoConfigForGivenUserClass()
{
- $this->expectException('\RuntimeException');
+ $this->expectException(\RuntimeException::class);
$this->expectExceptionMessage('No encoder has been configured for account "Foo\Bar\User".');
$this->passwordEncoderCommandTester->execute([
diff --git a/src/Symfony/Bundle/TwigBundle/Tests/Controller/PreviewErrorControllerTest.php b/src/Symfony/Bundle/TwigBundle/Tests/Controller/PreviewErrorControllerTest.php
index 63750cd2ab..e485f43720 100644
--- a/src/Symfony/Bundle/TwigBundle/Tests/Controller/PreviewErrorControllerTest.php
+++ b/src/Symfony/Bundle/TwigBundle/Tests/Controller/PreviewErrorControllerTest.php
@@ -30,7 +30,7 @@ class PreviewErrorControllerTest extends TestCase
$code = 123;
$logicalControllerName = 'foo:bar:baz';
- $kernel = $this->getMockBuilder('\Symfony\Component\HttpKernel\HttpKernelInterface')->getMock();
+ $kernel = $this->getMockBuilder(HttpKernelInterface::class)->getMock();
$kernel
->expects($this->once())
->method('handle')
diff --git a/src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/Compiler/ExtensionPassTest.php b/src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/Compiler/ExtensionPassTest.php
index add657d051..15529a9c61 100644
--- a/src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/Compiler/ExtensionPassTest.php
+++ b/src/Symfony/Bundle/TwigBundle/Tests/DependencyInjection/Compiler/ExtensionPassTest.php
@@ -12,10 +12,14 @@
namespace Symfony\Bundle\TwigBundle\Tests\DependencyInjection\Compiler;
use PHPUnit\Framework\TestCase;
+use Symfony\Bridge\Twig\AppVariable;
use Symfony\Bundle\TwigBundle\DependencyInjection\Compiler\ExtensionPass;
+use Symfony\Bundle\TwigBundle\Loader\FilesystemLoader;
use Symfony\Bundle\TwigBundle\TemplateIterator;
+use Symfony\Bundle\TwigBundle\TwigEngine;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Definition;
+use Twig\Loader\FilesystemLoader as TwigFilesystemLoader;
class ExtensionPassTest extends TestCase
{
@@ -24,17 +28,17 @@ class ExtensionPassTest extends TestCase
$container = new ContainerBuilder();
$container->setParameter('kernel.debug', false);
- $container->register('twig.app_variable', '\Symfony\Bridge\Twig\AppVariable');
- $container->register('templating', '\Symfony\Bundle\TwigBundle\TwigEngine');
+ $container->register('twig.app_variable', AppVariable::class);
+ $container->register('templating', TwigEngine::class);
$container->register('twig.extension.yaml');
$container->register('twig.extension.debug.stopwatch');
$container->register('twig.extension.expression');
- $nativeTwigLoader = new Definition('\Twig\Loader\FilesystemLoader');
+ $nativeTwigLoader = new Definition(TwigFilesystemLoader::class);
$nativeTwigLoader->addMethodCall('addPath', []);
$container->setDefinition('twig.loader.native_filesystem', $nativeTwigLoader);
- $filesystemLoader = new Definition('\Symfony\Bundle\TwigBundle\Loader\FilesystemLoader');
+ $filesystemLoader = new Definition(FilesystemLoader::class);
$filesystemLoader->setArguments([null, null, null]);
$filesystemLoader->addMethodCall('addPath', []);
$container->setDefinition('twig.loader.filesystem', $filesystemLoader);
diff --git a/src/Symfony/Component/BrowserKit/Tests/HttpBrowserTest.php b/src/Symfony/Component/BrowserKit/Tests/HttpBrowserTest.php
index 1397d9b10c..4cd44aff70 100644
--- a/src/Symfony/Component/BrowserKit/Tests/HttpBrowserTest.php
+++ b/src/Symfony/Component/BrowserKit/Tests/HttpBrowserTest.php
@@ -73,7 +73,7 @@ class HttpBrowserTest extends AbstractBrowserTest
->method('request')
->with('POST', 'http://example.com/', $this->callback(function ($options) {
$this->assertStringContainsString('Content-Type: multipart/form-data', implode('', $options['headers']));
- $this->assertInstanceOf('\Generator', $options['body']);
+ $this->assertInstanceOf(\Generator::class, $options['body']);
$this->assertStringContainsString('my_file', implode('', iterator_to_array($options['body'])));
return true;
@@ -183,7 +183,7 @@ class HttpBrowserTest extends AbstractBrowserTest
->method('request')
->with('POST', 'http://example.com/', $this->callback(function ($options) use ($fileContents) {
$this->assertStringContainsString('Content-Type: multipart/form-data', implode('', $options['headers']));
- $this->assertInstanceOf('\Generator', $options['body']);
+ $this->assertInstanceOf(\Generator::class, $options['body']);
$body = implode('', iterator_to_array($options['body'], false));
foreach ($fileContents as $content) {
$this->assertStringContainsString($content, $body);
@@ -201,7 +201,7 @@ class HttpBrowserTest extends AbstractBrowserTest
->method('request')
->with('POST', 'http://example.com/', $this->callback(function ($options) use ($fileContents) {
$this->assertStringContainsString('Content-Type: multipart/form-data', implode('', $options['headers']));
- $this->assertInstanceOf('\Generator', $options['body']);
+ $this->assertInstanceOf(\Generator::class, $options['body']);
$body = implode('', iterator_to_array($options['body'], false));
foreach ($fileContents as $content) {
$this->assertStringNotContainsString($content, $body);
diff --git a/src/Symfony/Component/Cache/Tests/Adapter/MemcachedAdapterTest.php b/src/Symfony/Component/Cache/Tests/Adapter/MemcachedAdapterTest.php
index 26609ff443..8de7a9d1b8 100644
--- a/src/Symfony/Component/Cache/Tests/Adapter/MemcachedAdapterTest.php
+++ b/src/Symfony/Component/Cache/Tests/Adapter/MemcachedAdapterTest.php
@@ -186,7 +186,7 @@ class MemcachedAdapterTest extends AdapterTestCase
public function provideDsnWithOptions(): iterable
{
- if (!class_exists('\Memcached')) {
+ if (!class_exists(\Memcached::class)) {
self::markTestSkipped('Extension memcached required.');
}
diff --git a/src/Symfony/Component/Config/Tests/ResourceCheckerConfigCacheTest.php b/src/Symfony/Component/Config/Tests/ResourceCheckerConfigCacheTest.php
index 8e0a2b32ba..bd66e615bf 100644
--- a/src/Symfony/Component/Config/Tests/ResourceCheckerConfigCacheTest.php
+++ b/src/Symfony/Component/Config/Tests/ResourceCheckerConfigCacheTest.php
@@ -14,6 +14,7 @@ namespace Symfony\Component\Config\Tests;
use PHPUnit\Framework\TestCase;
use Symfony\Component\Config\Resource\FileResource;
use Symfony\Component\Config\ResourceCheckerConfigCache;
+use Symfony\Component\Config\ResourceCheckerInterface;
use Symfony\Component\Config\Tests\Resource\ResourceStub;
class ResourceCheckerConfigCacheTest extends TestCase
@@ -45,7 +46,7 @@ class ResourceCheckerConfigCacheTest extends TestCase
public function testCacheIsNotFreshIfEmpty()
{
- $checker = $this->getMockBuilder('\Symfony\Component\Config\ResourceCheckerInterface')->getMock()
+ $checker = $this->getMockBuilder(ResourceCheckerInterface::class)->getMock()
->expects($this->never())->method('supports');
/* If there is nothing in the cache, it needs to be filled (and thus it's not fresh).
@@ -82,7 +83,7 @@ class ResourceCheckerConfigCacheTest extends TestCase
public function testIsFreshWithchecker()
{
- $checker = $this->getMockBuilder('\Symfony\Component\Config\ResourceCheckerInterface')->getMock();
+ $checker = $this->getMockBuilder(ResourceCheckerInterface::class)->getMock();
$checker->expects($this->once())
->method('supports')
@@ -100,7 +101,7 @@ class ResourceCheckerConfigCacheTest extends TestCase
public function testIsNotFreshWithchecker()
{
- $checker = $this->getMockBuilder('\Symfony\Component\Config\ResourceCheckerInterface')->getMock();
+ $checker = $this->getMockBuilder(ResourceCheckerInterface::class)->getMock();
$checker->expects($this->once())
->method('supports')
@@ -118,7 +119,7 @@ class ResourceCheckerConfigCacheTest extends TestCase
public function testCacheIsNotFreshWhenUnserializeFails()
{
- $checker = $this->getMockBuilder('\Symfony\Component\Config\ResourceCheckerInterface')->getMock();
+ $checker = $this->getMockBuilder(ResourceCheckerInterface::class)->getMock();
$cache = new ResourceCheckerConfigCache($this->cacheFile, [$checker]);
$cache->write('foo', [new FileResource(__FILE__)]);
@@ -138,7 +139,8 @@ class ResourceCheckerConfigCacheTest extends TestCase
public function testCacheIsNotFreshIfNotExistsMetaFile()
{
- $checker = $this->getMockBuilder('\Symfony\Component\Config\ResourceCheckerInterface')->getMock();
+ $checker = $this->getMockBuilder(ResourceCheckerInterface::class
+ )->getMock();
$cache = new ResourceCheckerConfigCache($this->cacheFile, [$checker]);
$cache->write('foo', [new FileResource(__FILE__)]);
diff --git a/src/Symfony/Component/Console/Tests/ApplicationTest.php b/src/Symfony/Component/Console/Tests/ApplicationTest.php
index c62ac5b3e7..8361635aeb 100644
--- a/src/Symfony/Component/Console/Tests/ApplicationTest.php
+++ b/src/Symfony/Component/Console/Tests/ApplicationTest.php
@@ -777,7 +777,7 @@ class ApplicationTest extends TestCase
$tester->run(['command' => 'foo'], ['decorated' => false]);
$this->fail('->setCatchExceptions() sets the catch exception flag');
} catch (\Exception $e) {
- $this->assertInstanceOf('\Exception', $e, '->setCatchExceptions() sets the catch exception flag');
+ $this->assertInstanceOf(\Exception::class, $e, '->setCatchExceptions() sets the catch exception flag');
$this->assertEquals('Command "foo" is not defined.', $e->getMessage(), '->setCatchExceptions() sets the catch exception flag');
}
}
diff --git a/src/Symfony/Component/Console/Tests/Formatter/OutputFormatterStyleTest.php b/src/Symfony/Component/Console/Tests/Formatter/OutputFormatterStyleTest.php
index 2bcbe51940..7c1a422301 100644
--- a/src/Symfony/Component/Console/Tests/Formatter/OutputFormatterStyleTest.php
+++ b/src/Symfony/Component/Console/Tests/Formatter/OutputFormatterStyleTest.php
@@ -85,7 +85,7 @@ class OutputFormatterStyleTest extends TestCase
$style->setOption('foo');
$this->fail('->setOption() throws an \InvalidArgumentException when the option does not exist in the available options');
} catch (\Exception $e) {
- $this->assertInstanceOf('\InvalidArgumentException', $e, '->setOption() throws an \InvalidArgumentException when the option does not exist in the available options');
+ $this->assertInstanceOf(\InvalidArgumentException::class, $e, '->setOption() throws an \InvalidArgumentException when the option does not exist in the available options');
$this->assertStringContainsString('Invalid option specified: "foo"', $e->getMessage(), '->setOption() throws an \InvalidArgumentException when the option does not exist in the available options');
}
@@ -93,7 +93,7 @@ class OutputFormatterStyleTest extends TestCase
$style->unsetOption('foo');
$this->fail('->unsetOption() throws an \InvalidArgumentException when the option does not exist in the available options');
} catch (\Exception $e) {
- $this->assertInstanceOf('\InvalidArgumentException', $e, '->unsetOption() throws an \InvalidArgumentException when the option does not exist in the available options');
+ $this->assertInstanceOf(\InvalidArgumentException::class, $e, '->unsetOption() throws an \InvalidArgumentException when the option does not exist in the available options');
$this->assertStringContainsString('Invalid option specified: "foo"', $e->getMessage(), '->unsetOption() throws an \InvalidArgumentException when the option does not exist in the available options');
}
}
diff --git a/src/Symfony/Component/Console/Tests/Helper/HelperSetTest.php b/src/Symfony/Component/Console/Tests/Helper/HelperSetTest.php
index d608f7bfd2..9a8ca07bc6 100644
--- a/src/Symfony/Component/Console/Tests/Helper/HelperSetTest.php
+++ b/src/Symfony/Component/Console/Tests/Helper/HelperSetTest.php
@@ -13,6 +13,7 @@ namespace Symfony\Component\Console\Tests\Helper;
use PHPUnit\Framework\TestCase;
use Symfony\Component\Console\Command\Command;
+use Symfony\Component\Console\Helper\HelperInterface;
use Symfony\Component\Console\Helper\HelperSet;
class HelperSetTest extends TestCase
@@ -66,7 +67,7 @@ class HelperSetTest extends TestCase
$helperset->get('foo');
$this->fail('->get() throws InvalidArgumentException when helper not found');
} catch (\Exception $e) {
- $this->assertInstanceOf('\InvalidArgumentException', $e, '->get() throws InvalidArgumentException when helper not found');
+ $this->assertInstanceOf(\InvalidArgumentException::class, $e, '->get() throws InvalidArgumentException when helper not found');
$this->assertInstanceOf('Symfony\Component\Console\Exception\ExceptionInterface', $e, '->get() throws domain specific exception when helper not found');
$this->assertStringContainsString('The helper "foo" is not defined.', $e->getMessage(), '->get() throws InvalidArgumentException when helper not found');
}
@@ -111,7 +112,7 @@ class HelperSetTest extends TestCase
private function getGenericMockHelper($name, HelperSet $helperset = null)
{
- $mock_helper = $this->getMockBuilder('\Symfony\Component\Console\Helper\HelperInterface')->getMock();
+ $mock_helper = $this->getMockBuilder(HelperInterface::class)->getMock();
$mock_helper->expects($this->any())
->method('getName')
->willReturn($name);
diff --git a/src/Symfony/Component/Console/Tests/Helper/QuestionHelperTest.php b/src/Symfony/Component/Console/Tests/Helper/QuestionHelperTest.php
index 094559e8c1..871524e444 100644
--- a/src/Symfony/Component/Console/Tests/Helper/QuestionHelperTest.php
+++ b/src/Symfony/Component/Console/Tests/Helper/QuestionHelperTest.php
@@ -17,6 +17,7 @@ use Symfony\Component\Console\Formatter\OutputFormatter;
use Symfony\Component\Console\Helper\FormatterHelper;
use Symfony\Component\Console\Helper\HelperSet;
use Symfony\Component\Console\Helper\QuestionHelper;
+use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Output\StreamOutput;
use Symfony\Component\Console\Question\ChoiceQuestion;
use Symfony\Component\Console\Question\ConfirmationQuestion;
@@ -684,7 +685,7 @@ class QuestionHelperTest extends AbstractQuestionHelperTest
' [żółw ] bar',
' [łabądź] baz',
];
- $output = $this->getMockBuilder('\Symfony\Component\Console\Output\OutputInterface')->getMock();
+ $output = $this->getMockBuilder(OutputInterface::class)->getMock();
$output->method('getFormatter')->willReturn(new OutputFormatter());
$dialog = new QuestionHelper();
diff --git a/src/Symfony/Component/Debug/Tests/Exception/FlattenExceptionTest.php b/src/Symfony/Component/Debug/Tests/Exception/FlattenExceptionTest.php
index 6d89a0ce61..ea441b3081 100644
--- a/src/Symfony/Component/Debug/Tests/Exception/FlattenExceptionTest.php
+++ b/src/Symfony/Component/Debug/Tests/Exception/FlattenExceptionTest.php
@@ -286,7 +286,7 @@ class FlattenExceptionTest extends TestCase
$args = $array[$i++];
$this->assertSame($args[0], 'object');
- $this->assertTrue('Closure' === $args[1] || is_subclass_of($args[1], '\Closure'), 'Expect object class name to be Closure or a subclass of Closure.');
+ $this->assertTrue('Closure' === $args[1] || is_subclass_of($args[1], \Closure::class), 'Expect object class name to be Closure or a subclass of Closure.');
$this->assertSame(['array', [['integer', 1], ['integer', 2]]], $array[$i++]);
$this->assertSame(['array', ['foo' => ['integer', 123]]], $array[$i++]);
diff --git a/src/Symfony/Component/DependencyInjection/Tests/Compiler/ResolveClassPassTest.php b/src/Symfony/Component/DependencyInjection/Tests/Compiler/ResolveClassPassTest.php
index 81e05fb284..520c2245d7 100644
--- a/src/Symfony/Component/DependencyInjection/Tests/Compiler/ResolveClassPassTest.php
+++ b/src/Symfony/Component/DependencyInjection/Tests/Compiler/ResolveClassPassTest.php
@@ -55,7 +55,7 @@ class ResolveClassPassTest extends TestCase
{
yield [\stdClass::class];
yield ['bar'];
- yield ['\DateTime'];
+ yield [\DateTime::class];
}
public function testNonFqcnChildDefinition()
diff --git a/src/Symfony/Component/DependencyInjection/Tests/ContainerBuilderTest.php b/src/Symfony/Component/DependencyInjection/Tests/ContainerBuilderTest.php
index 8986232c8c..8ffe22e664 100644
--- a/src/Symfony/Component/DependencyInjection/Tests/ContainerBuilderTest.php
+++ b/src/Symfony/Component/DependencyInjection/Tests/ContainerBuilderTest.php
@@ -412,7 +412,7 @@ class ContainerBuilderTest extends TestCase
$builder = new ContainerBuilder();
$builder->register('foo1', '%class%');
$builder->setParameter('class', 'stdClass');
- $this->assertInstanceOf('\stdClass', $builder->get('foo1'), '->createService() replaces parameters in the class provided by the service definition');
+ $this->assertInstanceOf(\stdClass::class, $builder->get('foo1'), '->createService() replaces parameters in the class provided by the service definition');
}
public function testCreateServiceArguments()
@@ -511,7 +511,7 @@ class ContainerBuilderTest extends TestCase
foreach ($lazyContext->lazyValues as $k => $v) {
++$i;
$this->assertEquals('k1', $k);
- $this->assertInstanceOf('\stdClass', $v);
+ $this->assertInstanceOf(\stdClass::class, $v);
}
// The second argument should have been ignored.
diff --git a/src/Symfony/Component/DependencyInjection/Tests/ContainerTest.php b/src/Symfony/Component/DependencyInjection/Tests/ContainerTest.php
index 9015bf6b4f..ff6f483364 100644
--- a/src/Symfony/Component/DependencyInjection/Tests/ContainerTest.php
+++ b/src/Symfony/Component/DependencyInjection/Tests/ContainerTest.php
@@ -14,6 +14,7 @@ namespace Symfony\Component\DependencyInjection\Tests;
use PHPUnit\Framework\TestCase;
use Symfony\Component\DependencyInjection\Container;
use Symfony\Component\DependencyInjection\ContainerInterface;
+use Symfony\Component\DependencyInjection\Exception\ServiceCircularReferenceException;
use Symfony\Component\DependencyInjection\ParameterBag\FrozenParameterBag;
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBag;
use Symfony\Contracts\Service\ResetInterface;
@@ -116,7 +117,7 @@ class ContainerTest extends TestCase
$sc->getParameter('baba');
$this->fail('->getParameter() thrown an \InvalidArgumentException if the key does not exist');
} catch (\Exception $e) {
- $this->assertInstanceOf('\InvalidArgumentException', $e, '->getParameter() thrown an \InvalidArgumentException if the key does not exist');
+ $this->assertInstanceOf(\InvalidArgumentException::class, $e, '->getParameter() thrown an \InvalidArgumentException if the key does not exist');
$this->assertEquals('You have requested a non-existent parameter "baba".', $e->getMessage(), '->getParameter() thrown an \InvalidArgumentException if the key does not exist');
}
}
@@ -252,7 +253,7 @@ class ContainerTest extends TestCase
$sc->get('circular');
$this->fail('->get() throws a ServiceCircularReferenceException if it contains circular reference');
} catch (\Exception $e) {
- $this->assertInstanceOf('\Symfony\Component\DependencyInjection\Exception\ServiceCircularReferenceException', $e, '->get() throws a ServiceCircularReferenceException if it contains circular reference');
+ $this->assertInstanceOf(ServiceCircularReferenceException::class, $e, '->get() throws a ServiceCircularReferenceException if it contains circular reference');
$this->assertStringStartsWith('Circular reference detected for service "circular"', $e->getMessage(), '->get() throws a \LogicException if it contains circular reference');
}
}
diff --git a/src/Symfony/Component/DependencyInjection/Tests/Dumper/PhpDumperTest.php b/src/Symfony/Component/DependencyInjection/Tests/Dumper/PhpDumperTest.php
index 9f17269846..365cbc3461 100644
--- a/src/Symfony/Component/DependencyInjection/Tests/Dumper/PhpDumperTest.php
+++ b/src/Symfony/Component/DependencyInjection/Tests/Dumper/PhpDumperTest.php
@@ -211,7 +211,7 @@ class PhpDumperTest extends TestCase
$dumper->dump();
$this->fail('->dump() throws a RuntimeException if the container to be dumped has reference to objects or resources');
} catch (\Exception $e) {
- $this->assertInstanceOf('\Symfony\Component\DependencyInjection\Exception\RuntimeException', $e, '->dump() throws a RuntimeException if the container to be dumped has reference to objects or resources');
+ $this->assertInstanceOf(RuntimeException::class, $e, '->dump() throws a RuntimeException if the container to be dumped has reference to objects or resources');
$this->assertEquals('Unable to dump a service container if a parameter is an object or a resource.', $e->getMessage(), '->dump() throws a RuntimeException if the container to be dumped has reference to objects or resources');
}
}
diff --git a/src/Symfony/Component/DependencyInjection/Tests/Dumper/XmlDumperTest.php b/src/Symfony/Component/DependencyInjection/Tests/Dumper/XmlDumperTest.php
index 4472782820..ec68d8b4ea 100644
--- a/src/Symfony/Component/DependencyInjection/Tests/Dumper/XmlDumperTest.php
+++ b/src/Symfony/Component/DependencyInjection/Tests/Dumper/XmlDumperTest.php
@@ -64,7 +64,7 @@ class XmlDumperTest extends TestCase
$dumper->dump();
$this->fail('->dump() throws a RuntimeException if the container to be dumped has reference to objects or resources');
} catch (\Exception $e) {
- $this->assertInstanceOf('\RuntimeException', $e, '->dump() throws a RuntimeException if the container to be dumped has reference to objects or resources');
+ $this->assertInstanceOf(\RuntimeException::class, $e, '->dump() throws a RuntimeException if the container to be dumped has reference to objects or resources');
$this->assertEquals('Unable to dump a service container if a parameter is an object or a resource.', $e->getMessage(), '->dump() throws a RuntimeException if the container to be dumped has reference to objects or resources');
}
}
diff --git a/src/Symfony/Component/DependencyInjection/Tests/Dumper/YamlDumperTest.php b/src/Symfony/Component/DependencyInjection/Tests/Dumper/YamlDumperTest.php
index 7a83b2e6a1..b787615254 100644
--- a/src/Symfony/Component/DependencyInjection/Tests/Dumper/YamlDumperTest.php
+++ b/src/Symfony/Component/DependencyInjection/Tests/Dumper/YamlDumperTest.php
@@ -59,7 +59,7 @@ class YamlDumperTest extends TestCase
$dumper->dump();
$this->fail('->dump() throws a RuntimeException if the container to be dumped has reference to objects or resources');
} catch (\Exception $e) {
- $this->assertInstanceOf('\RuntimeException', $e, '->dump() throws a RuntimeException if the container to be dumped has reference to objects or resources');
+ $this->assertInstanceOf(\RuntimeException::class, $e, '->dump() throws a RuntimeException if the container to be dumped has reference to objects or resources');
$this->assertEquals('Unable to dump a service container if a parameter is an object or a resource.', $e->getMessage(), '->dump() throws a RuntimeException if the container to be dumped has reference to objects or resources');
}
}
diff --git a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/containers/container9.php b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/containers/container9.php
index 6ae7f7161a..3ea49503e9 100644
--- a/src/Symfony/Component/DependencyInjection/Tests/Fixtures/containers/container9.php
+++ b/src/Symfony/Component/DependencyInjection/Tests/Fixtures/containers/container9.php
@@ -3,6 +3,7 @@
require_once __DIR__.'/../includes/classes.php';
require_once __DIR__.'/../includes/foo.php';
+use Bar\FooClass;
use Symfony\Component\DependencyInjection\Argument\IteratorArgument;
use Symfony\Component\DependencyInjection\Argument\TaggedIteratorArgument;
use Symfony\Component\DependencyInjection\ContainerBuilder;
@@ -13,7 +14,7 @@ use Symfony\Component\ExpressionLanguage\Expression;
$container = new ContainerBuilder();
$container
- ->register('foo', '\Bar\FooClass')
+ ->register('foo', FooClass::class)
->addTag('foo', ['foo' => 'foo'])
->addTag('foo', ['bar' => 'bar', 'baz' => 'baz'])
->setFactory(['Bar\\FooClass', 'getInstance'])
diff --git a/src/Symfony/Component/DependencyInjection/Tests/Loader/XmlFileLoaderTest.php b/src/Symfony/Component/DependencyInjection/Tests/Loader/XmlFileLoaderTest.php
index 1df8d536ee..e09bca14fb 100644
--- a/src/Symfony/Component/DependencyInjection/Tests/Loader/XmlFileLoaderTest.php
+++ b/src/Symfony/Component/DependencyInjection/Tests/Loader/XmlFileLoaderTest.php
@@ -507,7 +507,7 @@ class XmlFileLoaderTest extends TestCase
$loader->load('extensions/services4.xml');
$this->fail('->load() throws an InvalidArgumentException if the tag is not valid');
} catch (\Exception $e) {
- $this->assertInstanceOf('\InvalidArgumentException', $e, '->load() throws an InvalidArgumentException if the tag is not valid');
+ $this->assertInstanceOf(\InvalidArgumentException::class, $e, '->load() throws an InvalidArgumentException if the tag is not valid');
$this->assertStringStartsWith('There is no extension able to load the configuration for "project:bar" (in', $e->getMessage(), '->load() throws an InvalidArgumentException if the tag is not valid');
}
}
diff --git a/src/Symfony/Component/DependencyInjection/Tests/Loader/YamlFileLoaderTest.php b/src/Symfony/Component/DependencyInjection/Tests/Loader/YamlFileLoaderTest.php
index 507a7f0220..e79e6f58cc 100644
--- a/src/Symfony/Component/DependencyInjection/Tests/Loader/YamlFileLoaderTest.php
+++ b/src/Symfony/Component/DependencyInjection/Tests/Loader/YamlFileLoaderTest.php
@@ -285,7 +285,7 @@ class YamlFileLoaderTest extends TestCase
$loader->load('services11.yml');
$this->fail('->load() throws an InvalidArgumentException if the tag is not valid');
} catch (\Exception $e) {
- $this->assertInstanceOf('\InvalidArgumentException', $e, '->load() throws an InvalidArgumentException if the tag is not valid');
+ $this->assertInstanceOf(\InvalidArgumentException::class, $e, '->load() throws an InvalidArgumentException if the tag is not valid');
$this->assertStringStartsWith('There is no extension able to load the configuration for "foobarfoobar" (in', $e->getMessage(), '->load() throws an InvalidArgumentException if the tag is not valid');
}
}
diff --git a/src/Symfony/Component/ErrorHandler/Tests/Exception/FlattenExceptionTest.php b/src/Symfony/Component/ErrorHandler/Tests/Exception/FlattenExceptionTest.php
index 187166400c..5dff13aaaa 100644
--- a/src/Symfony/Component/ErrorHandler/Tests/Exception/FlattenExceptionTest.php
+++ b/src/Symfony/Component/ErrorHandler/Tests/Exception/FlattenExceptionTest.php
@@ -304,7 +304,7 @@ class FlattenExceptionTest extends TestCase
$args = $array[$i++];
$this->assertSame('object', $args[0]);
- $this->assertTrue('Closure' === $args[1] || is_subclass_of($args[1], '\Closure'), 'Expect object class name to be Closure or a subclass of Closure.');
+ $this->assertTrue('Closure' === $args[1] || is_subclass_of($args[1], \Closure::class), 'Expect object class name to be Closure or a subclass of Closure.');
$this->assertSame(['array', [['integer', 1], ['integer', 2]]], $array[$i++]);
$this->assertSame(['array', ['foo' => ['integer', 123]]], $array[$i++]);
diff --git a/src/Symfony/Component/EventDispatcher/Tests/GenericEventTest.php b/src/Symfony/Component/EventDispatcher/Tests/GenericEventTest.php
index 484e1a5f3e..d13d53629f 100644
--- a/src/Symfony/Component/EventDispatcher/Tests/GenericEventTest.php
+++ b/src/Symfony/Component/EventDispatcher/Tests/GenericEventTest.php
@@ -80,7 +80,7 @@ class GenericEventTest extends TestCase
public function testGetArgException()
{
- $this->expectException('\InvalidArgumentException');
+ $this->expectException(\InvalidArgumentException::class);
$this->event->getArgument('nameNotExist');
}
@@ -90,7 +90,7 @@ class GenericEventTest extends TestCase
$this->assertEquals('Event', $this->event['name']);
// test getting invalid arg
- $this->expectException('InvalidArgumentException');
+ $this->expectException(\InvalidArgumentException::class);
$this->assertFalse($this->event['nameNotExist']);
}
diff --git a/src/Symfony/Component/EventDispatcher/Tests/ImmutableEventDispatcherTest.php b/src/Symfony/Component/EventDispatcher/Tests/ImmutableEventDispatcherTest.php
index 1a33c19b15..e0b99f9086 100644
--- a/src/Symfony/Component/EventDispatcher/Tests/ImmutableEventDispatcherTest.php
+++ b/src/Symfony/Component/EventDispatcher/Tests/ImmutableEventDispatcherTest.php
@@ -72,13 +72,13 @@ class ImmutableEventDispatcherTest extends TestCase
public function testAddListenerDisallowed()
{
- $this->expectException('\BadMethodCallException');
+ $this->expectException(\BadMethodCallException::class);
$this->dispatcher->addListener('event', function () { return 'foo'; });
}
public function testAddSubscriberDisallowed()
{
- $this->expectException('\BadMethodCallException');
+ $this->expectException(\BadMethodCallException::class);
$subscriber = $this->getMockBuilder('Symfony\Component\EventDispatcher\EventSubscriberInterface')->getMock();
$this->dispatcher->addSubscriber($subscriber);
@@ -86,13 +86,13 @@ class ImmutableEventDispatcherTest extends TestCase
public function testRemoveListenerDisallowed()
{
- $this->expectException('\BadMethodCallException');
+ $this->expectException(\BadMethodCallException::class);
$this->dispatcher->removeListener('event', function () { return 'foo'; });
}
public function testRemoveSubscriberDisallowed()
{
- $this->expectException('\BadMethodCallException');
+ $this->expectException(\BadMethodCallException::class);
$subscriber = $this->getMockBuilder('Symfony\Component\EventDispatcher\EventSubscriberInterface')->getMock();
$this->dispatcher->removeSubscriber($subscriber);
diff --git a/src/Symfony/Component/Form/Extension/Core/DataTransformer/DateIntervalToArrayTransformer.php b/src/Symfony/Component/Form/Extension/Core/DataTransformer/DateIntervalToArrayTransformer.php
index dddd074a77..3f6c23f555 100644
--- a/src/Symfony/Component/Form/Extension/Core/DataTransformer/DateIntervalToArrayTransformer.php
+++ b/src/Symfony/Component/Form/Extension/Core/DataTransformer/DateIntervalToArrayTransformer.php
@@ -82,7 +82,7 @@ class DateIntervalToArrayTransformer implements DataTransformerInterface
);
}
if (!$dateInterval instanceof \DateInterval) {
- throw new UnexpectedTypeException($dateInterval, '\DateInterval');
+ throw new UnexpectedTypeException($dateInterval, \DateInterval::class);
}
$result = [];
foreach (self::$availableFields as $field => $char) {
diff --git a/src/Symfony/Component/Form/Extension/Core/DataTransformer/DateIntervalToStringTransformer.php b/src/Symfony/Component/Form/Extension/Core/DataTransformer/DateIntervalToStringTransformer.php
index 5b79ae82eb..8ae0cdb666 100644
--- a/src/Symfony/Component/Form/Extension/Core/DataTransformer/DateIntervalToStringTransformer.php
+++ b/src/Symfony/Component/Form/Extension/Core/DataTransformer/DateIntervalToStringTransformer.php
@@ -51,7 +51,7 @@ class DateIntervalToStringTransformer implements DataTransformerInterface
return '';
}
if (!$value instanceof \DateInterval) {
- throw new UnexpectedTypeException($value, '\DateInterval');
+ throw new UnexpectedTypeException($value, \DateInterval::class);
}
return $value->format($this->format);
diff --git a/src/Symfony/Component/Form/Extension/Core/Type/ChoiceType.php b/src/Symfony/Component/Form/Extension/Core/Type/ChoiceType.php
index dce846f10e..4297460d34 100644
--- a/src/Symfony/Component/Form/Extension/Core/Type/ChoiceType.php
+++ b/src/Symfony/Component/Form/Extension/Core/Type/ChoiceType.php
@@ -17,6 +17,7 @@ use Symfony\Component\Form\ChoiceList\Factory\CachingFactoryDecorator;
use Symfony\Component\Form\ChoiceList\Factory\ChoiceListFactoryInterface;
use Symfony\Component\Form\ChoiceList\Factory\DefaultChoiceListFactory;
use Symfony\Component\Form\ChoiceList\Factory\PropertyAccessDecorator;
+use Symfony\Component\Form\ChoiceList\Loader\ChoiceLoaderInterface;
use Symfony\Component\Form\ChoiceList\View\ChoiceGroupView;
use Symfony\Component\Form\ChoiceList\View\ChoiceListView;
use Symfony\Component\Form\ChoiceList\View\ChoiceView;
@@ -33,6 +34,7 @@ use Symfony\Component\Form\FormInterface;
use Symfony\Component\Form\FormView;
use Symfony\Component\OptionsResolver\Options;
use Symfony\Component\OptionsResolver\OptionsResolver;
+use Symfony\Component\PropertyAccess\PropertyPath;
class ChoiceType extends AbstractType
{
@@ -322,15 +324,15 @@ class ChoiceType extends AbstractType
$resolver->setNormalizer('placeholder', $placeholderNormalizer);
$resolver->setNormalizer('choice_translation_domain', $choiceTranslationDomainNormalizer);
- $resolver->setAllowedTypes('choices', ['null', 'array', '\Traversable']);
+ $resolver->setAllowedTypes('choices', ['null', 'array', \Traversable::class]);
$resolver->setAllowedTypes('choice_translation_domain', ['null', 'bool', 'string']);
- $resolver->setAllowedTypes('choice_loader', ['null', 'Symfony\Component\Form\ChoiceList\Loader\ChoiceLoaderInterface']);
- $resolver->setAllowedTypes('choice_label', ['null', 'bool', 'callable', 'string', 'Symfony\Component\PropertyAccess\PropertyPath']);
- $resolver->setAllowedTypes('choice_name', ['null', 'callable', 'string', 'Symfony\Component\PropertyAccess\PropertyPath']);
- $resolver->setAllowedTypes('choice_value', ['null', 'callable', 'string', 'Symfony\Component\PropertyAccess\PropertyPath']);
- $resolver->setAllowedTypes('choice_attr', ['null', 'array', 'callable', 'string', 'Symfony\Component\PropertyAccess\PropertyPath']);
- $resolver->setAllowedTypes('preferred_choices', ['array', '\Traversable', 'callable', 'string', 'Symfony\Component\PropertyAccess\PropertyPath']);
- $resolver->setAllowedTypes('group_by', ['null', 'callable', 'string', 'Symfony\Component\PropertyAccess\PropertyPath']);
+ $resolver->setAllowedTypes('choice_loader', ['null', ChoiceLoaderInterface::class]);
+ $resolver->setAllowedTypes('choice_label', ['null', 'bool', 'callable', 'string', PropertyPath::class]);
+ $resolver->setAllowedTypes('choice_name', ['null', 'callable', 'string', PropertyPath::class]);
+ $resolver->setAllowedTypes('choice_value', ['null', 'callable', 'string', PropertyPath::class]);
+ $resolver->setAllowedTypes('choice_attr', ['null', 'array', 'callable', 'string', PropertyPath::class]);
+ $resolver->setAllowedTypes('preferred_choices', ['array', \Traversable::class, 'callable', 'string', PropertyPath::class]);
+ $resolver->setAllowedTypes('group_by', ['null', 'callable', 'string', PropertyPath::class]);
}
/**
diff --git a/src/Symfony/Component/Form/Tests/ButtonBuilderTest.php b/src/Symfony/Component/Form/Tests/ButtonBuilderTest.php
index 7bd78896d1..70b54f0b5f 100644
--- a/src/Symfony/Component/Form/Tests/ButtonBuilderTest.php
+++ b/src/Symfony/Component/Form/Tests/ButtonBuilderTest.php
@@ -36,7 +36,7 @@ class ButtonBuilderTest extends TestCase
*/
public function testValidNames($name)
{
- $this->assertInstanceOf('\Symfony\Component\Form\ButtonBuilder', new ButtonBuilder($name));
+ $this->assertInstanceOf(ButtonBuilder::class, new ButtonBuilder($name));
}
/**
@@ -44,7 +44,7 @@ class ButtonBuilderTest extends TestCase
*/
public function testNameContainingIllegalCharacters()
{
- $this->assertInstanceOf('\Symfony\Component\Form\ButtonBuilder', new ButtonBuilder('button[]'));
+ $this->assertInstanceOf(ButtonBuilder::class, new ButtonBuilder('button[]'));
}
public function getInvalidNames()
diff --git a/src/Symfony/Component/Form/Tests/ChoiceList/Factory/PropertyAccessDecoratorTest.php b/src/Symfony/Component/Form/Tests/ChoiceList/Factory/PropertyAccessDecoratorTest.php
index df3a6bb705..96df5959be 100644
--- a/src/Symfony/Component/Form/Tests/ChoiceList/Factory/PropertyAccessDecoratorTest.php
+++ b/src/Symfony/Component/Form/Tests/ChoiceList/Factory/PropertyAccessDecoratorTest.php
@@ -45,7 +45,7 @@ class PropertyAccessDecoratorTest extends TestCase
$this->decoratedFactory->expects($this->once())
->method('createListFromChoices')
- ->with($choices, $this->isInstanceOf('\Closure'))
+ ->with($choices, $this->isInstanceOf(\Closure::class))
->willReturnCallback(function ($choices, $callback) {
return new ArrayChoiceList(array_map($callback, $choices));
});
@@ -59,7 +59,7 @@ class PropertyAccessDecoratorTest extends TestCase
$this->decoratedFactory->expects($this->once())
->method('createListFromChoices')
- ->with($choices, $this->isInstanceOf('\Closure'))
+ ->with($choices, $this->isInstanceOf(\Closure::class))
->willReturnCallback(function ($choices, $callback) {
return new ArrayChoiceList(array_map($callback, $choices));
});
@@ -73,7 +73,7 @@ class PropertyAccessDecoratorTest extends TestCase
$this->decoratedFactory->expects($this->once())
->method('createListFromLoader')
- ->with($loader, $this->isInstanceOf('\Closure'))
+ ->with($loader, $this->isInstanceOf(\Closure::class))
->willReturnCallback(function ($loader, $callback) {
return new ArrayChoiceList((array) $callback((object) ['property' => 'value']));
});
@@ -88,7 +88,7 @@ class PropertyAccessDecoratorTest extends TestCase
$this->decoratedFactory->expects($this->once())
->method('createListFromChoices')
- ->with($choices, $this->isInstanceOf('\Closure'))
+ ->with($choices, $this->isInstanceOf(\Closure::class))
->willReturnCallback(function ($choices, $callback) {
return new ArrayChoiceList(array_map($callback, $choices));
});
@@ -103,7 +103,7 @@ class PropertyAccessDecoratorTest extends TestCase
$this->decoratedFactory->expects($this->once())
->method('createListFromLoader')
- ->with($loader, $this->isInstanceOf('\Closure'))
+ ->with($loader, $this->isInstanceOf(\Closure::class))
->willReturnCallback(function ($loader, $callback) {
return new ArrayChoiceList((array) $callback(null));
});
@@ -117,7 +117,7 @@ class PropertyAccessDecoratorTest extends TestCase
$this->decoratedFactory->expects($this->once())
->method('createListFromLoader')
- ->with($loader, $this->isInstanceOf('\Closure'))
+ ->with($loader, $this->isInstanceOf(\Closure::class))
->willReturnCallback(function ($loader, $callback) {
return new ArrayChoiceList((array) $callback((object) ['property' => 'value']));
});
@@ -131,7 +131,7 @@ class PropertyAccessDecoratorTest extends TestCase
$this->decoratedFactory->expects($this->once())
->method('createView')
- ->with($list, $this->isInstanceOf('\Closure'))
+ ->with($list, $this->isInstanceOf(\Closure::class))
->willReturnCallback(function ($list, $preferred) {
return new ChoiceListView((array) $preferred((object) ['property' => true]));
});
@@ -145,7 +145,7 @@ class PropertyAccessDecoratorTest extends TestCase
$this->decoratedFactory->expects($this->once())
->method('createView')
- ->with($list, $this->isInstanceOf('\Closure'))
+ ->with($list, $this->isInstanceOf(\Closure::class))
->willReturnCallback(function ($list, $preferred) {
return new ChoiceListView((array) $preferred((object) ['property' => true]));
});
@@ -160,7 +160,7 @@ class PropertyAccessDecoratorTest extends TestCase
$this->decoratedFactory->expects($this->once())
->method('createView')
- ->with($list, $this->isInstanceOf('\Closure'))
+ ->with($list, $this->isInstanceOf(\Closure::class))
->willReturnCallback(function ($list, $preferred) {
return new ChoiceListView((array) $preferred((object) ['category' => null]));
});
@@ -174,7 +174,7 @@ class PropertyAccessDecoratorTest extends TestCase
$this->decoratedFactory->expects($this->once())
->method('createView')
- ->with($list, null, $this->isInstanceOf('\Closure'))
+ ->with($list, null, $this->isInstanceOf(\Closure::class))
->willReturnCallback(function ($list, $preferred, $label) {
return new ChoiceListView((array) $label((object) ['property' => 'label']));
});
@@ -188,7 +188,7 @@ class PropertyAccessDecoratorTest extends TestCase
$this->decoratedFactory->expects($this->once())
->method('createView')
- ->with($list, null, $this->isInstanceOf('\Closure'))
+ ->with($list, null, $this->isInstanceOf(\Closure::class))
->willReturnCallback(function ($list, $preferred, $label) {
return new ChoiceListView((array) $label((object) ['property' => 'label']));
});
@@ -202,7 +202,7 @@ class PropertyAccessDecoratorTest extends TestCase
$this->decoratedFactory->expects($this->once())
->method('createView')
- ->with($list, null, null, $this->isInstanceOf('\Closure'))
+ ->with($list, null, null, $this->isInstanceOf(\Closure::class))
->willReturnCallback(function ($list, $preferred, $label, $index) {
return new ChoiceListView((array) $index((object) ['property' => 'index']));
});
@@ -216,7 +216,7 @@ class PropertyAccessDecoratorTest extends TestCase
$this->decoratedFactory->expects($this->once())
->method('createView')
- ->with($list, null, null, $this->isInstanceOf('\Closure'))
+ ->with($list, null, null, $this->isInstanceOf(\Closure::class))
->willReturnCallback(function ($list, $preferred, $label, $index) {
return new ChoiceListView((array) $index((object) ['property' => 'index']));
});
@@ -230,7 +230,7 @@ class PropertyAccessDecoratorTest extends TestCase
$this->decoratedFactory->expects($this->once())
->method('createView')
- ->with($list, null, null, null, $this->isInstanceOf('\Closure'))
+ ->with($list, null, null, null, $this->isInstanceOf(\Closure::class))
->willReturnCallback(function ($list, $preferred, $label, $index, $groupBy) {
return new ChoiceListView((array) $groupBy((object) ['property' => 'group']));
});
@@ -244,7 +244,7 @@ class PropertyAccessDecoratorTest extends TestCase
$this->decoratedFactory->expects($this->once())
->method('createView')
- ->with($list, null, null, null, $this->isInstanceOf('\Closure'))
+ ->with($list, null, null, null, $this->isInstanceOf(\Closure::class))
->willReturnCallback(function ($list, $preferred, $label, $index, $groupBy) {
return new ChoiceListView((array) $groupBy((object) ['property' => 'group']));
});
@@ -259,7 +259,7 @@ class PropertyAccessDecoratorTest extends TestCase
$this->decoratedFactory->expects($this->once())
->method('createView')
- ->with($list, null, null, null, $this->isInstanceOf('\Closure'))
+ ->with($list, null, null, null, $this->isInstanceOf(\Closure::class))
->willReturnCallback(function ($list, $preferred, $label, $index, $groupBy) {
return new ChoiceListView((array) $groupBy((object) ['group' => null]));
});
@@ -273,7 +273,7 @@ class PropertyAccessDecoratorTest extends TestCase
$this->decoratedFactory->expects($this->once())
->method('createView')
- ->with($list, null, null, null, null, $this->isInstanceOf('\Closure'))
+ ->with($list, null, null, null, null, $this->isInstanceOf(\Closure::class))
->willReturnCallback(function ($list, $preferred, $label, $index, $groupBy, $attr) {
return new ChoiceListView((array) $attr((object) ['property' => 'attr']));
});
@@ -287,7 +287,7 @@ class PropertyAccessDecoratorTest extends TestCase
$this->decoratedFactory->expects($this->once())
->method('createView')
- ->with($list, null, null, null, null, $this->isInstanceOf('\Closure'))
+ ->with($list, null, null, null, null, $this->isInstanceOf(\Closure::class))
->willReturnCallback(function ($list, $preferred, $label, $index, $groupBy, $attr) {
return new ChoiceListView((array) $attr((object) ['property' => 'attr']));
});
diff --git a/src/Symfony/Component/Form/Tests/ChoiceList/Loader/CallbackChoiceLoaderTest.php b/src/Symfony/Component/Form/Tests/ChoiceList/Loader/CallbackChoiceLoaderTest.php
index 1bb46d8f50..52dd5f8af5 100644
--- a/src/Symfony/Component/Form/Tests/ChoiceList/Loader/CallbackChoiceLoaderTest.php
+++ b/src/Symfony/Component/Form/Tests/ChoiceList/Loader/CallbackChoiceLoaderTest.php
@@ -12,6 +12,7 @@
namespace Symfony\Component\Form\Tests\ChoiceList\Loader;
use PHPUnit\Framework\TestCase;
+use Symfony\Component\Form\ChoiceList\ChoiceListInterface;
use Symfony\Component\Form\ChoiceList\LazyChoiceList;
use Symfony\Component\Form\ChoiceList\Loader\CallbackChoiceLoader;
@@ -63,7 +64,7 @@ class CallbackChoiceLoaderTest extends TestCase
public function testLoadChoiceList()
{
- $this->assertInstanceOf('\Symfony\Component\Form\ChoiceList\ChoiceListInterface', self::$loader->loadChoiceList(self::$value));
+ $this->assertInstanceOf(ChoiceListInterface::class, self::$loader->loadChoiceList(self::$value));
}
public function testLoadChoiceListOnlyOnce()
diff --git a/src/Symfony/Component/Form/Tests/CompoundFormTest.php b/src/Symfony/Component/Form/Tests/CompoundFormTest.php
index a5196a3b68..c586aaebf6 100644
--- a/src/Symfony/Component/Form/Tests/CompoundFormTest.php
+++ b/src/Symfony/Component/Form/Tests/CompoundFormTest.php
@@ -227,7 +227,7 @@ class CompoundFormTest extends AbstractFormTest
public function testAddUsingNameButNoType()
{
- $this->form = $this->getBuilder('name', null, '\stdClass')
+ $this->form = $this->getBuilder('name', null, \stdClass::class)
->setCompound(true)
->setDataMapper($this->getDataMapper())
->getForm();
@@ -236,7 +236,7 @@ class CompoundFormTest extends AbstractFormTest
$this->factory->expects($this->once())
->method('createForProperty')
- ->with('\stdClass', 'foo')
+ ->with(\stdClass::class, 'foo')
->willReturn($child);
$this->form->add('foo');
@@ -248,7 +248,7 @@ class CompoundFormTest extends AbstractFormTest
public function testAddUsingNameButNoTypeAndOptions()
{
- $this->form = $this->getBuilder('name', null, '\stdClass')
+ $this->form = $this->getBuilder('name', null, \stdClass::class)
->setCompound(true)
->setDataMapper($this->getDataMapper())
->getForm();
@@ -257,7 +257,7 @@ class CompoundFormTest extends AbstractFormTest
$this->factory->expects($this->once())
->method('createForProperty')
- ->with('\stdClass', 'foo', null, [
+ ->with(\stdClass::class, 'foo', null, [
'bar' => 'baz',
'auto_initialize' => false,
])
@@ -348,7 +348,7 @@ class CompoundFormTest extends AbstractFormTest
$child = $this->getBuilder()->getForm();
$mapper->expects($this->once())
->method('mapDataToForms')
- ->with('bar', $this->isInstanceOf('\RecursiveIteratorIterator'))
+ ->with('bar', $this->isInstanceOf(\RecursiveIteratorIterator::class))
->willReturnCallback(function ($data, \RecursiveIteratorIterator $iterator) use ($child) {
$this->assertInstanceOf('Symfony\Component\Form\Util\InheritDataAwareIterator', $iterator->getInnerIterator());
$this->assertSame([$child->getName() => $child], iterator_to_array($iterator));
@@ -438,7 +438,7 @@ class CompoundFormTest extends AbstractFormTest
$mapper->expects($this->once())
->method('mapDataToForms')
- ->with('bar', $this->isInstanceOf('\RecursiveIteratorIterator'))
+ ->with('bar', $this->isInstanceOf(\RecursiveIteratorIterator::class))
->willReturnCallback(function ($data, \RecursiveIteratorIterator $iterator) use ($child1, $child2) {
$this->assertInstanceOf('Symfony\Component\Form\Util\InheritDataAwareIterator', $iterator->getInnerIterator());
$this->assertSame(['firstName' => $child1, 'lastName' => $child2], iterator_to_array($iterator));
diff --git a/src/Symfony/Component/Form/Tests/Extension/Core/EventListener/MergeCollectionListenerArrayObjectTest.php b/src/Symfony/Component/Form/Tests/Extension/Core/EventListener/MergeCollectionListenerArrayObjectTest.php
index 5944537927..5de0ea607a 100644
--- a/src/Symfony/Component/Form/Tests/Extension/Core/EventListener/MergeCollectionListenerArrayObjectTest.php
+++ b/src/Symfony/Component/Form/Tests/Extension/Core/EventListener/MergeCollectionListenerArrayObjectTest.php
@@ -24,6 +24,6 @@ class MergeCollectionListenerArrayObjectTest extends MergeCollectionListenerTest
protected function getBuilder($name = 'name')
{
- return new FormBuilder($name, '\ArrayObject', new EventDispatcher(), (new FormFactoryBuilder())->getFormFactory());
+ return new FormBuilder($name, \ArrayObject::class, new EventDispatcher(), (new FormFactoryBuilder())->getFormFactory());
}
}
diff --git a/src/Symfony/Component/Form/Tests/Extension/Csrf/EventListener/CsrfValidationListenerTest.php b/src/Symfony/Component/Form/Tests/Extension/Csrf/EventListener/CsrfValidationListenerTest.php
index 37d7594bef..0debb9e777 100644
--- a/src/Symfony/Component/Form/Tests/Extension/Csrf/EventListener/CsrfValidationListenerTest.php
+++ b/src/Symfony/Component/Form/Tests/Extension/Csrf/EventListener/CsrfValidationListenerTest.php
@@ -18,6 +18,7 @@ use Symfony\Component\Form\Extension\Csrf\EventListener\CsrfValidationListener;
use Symfony\Component\Form\FormBuilder;
use Symfony\Component\Form\FormEvent;
use Symfony\Component\Form\FormFactoryBuilder;
+use Symfony\Component\Form\Util\ServerParams;
use Symfony\Component\Security\Csrf\CsrfTokenManager;
class CsrfValidationListenerTest extends TestCase
@@ -76,7 +77,7 @@ class CsrfValidationListenerTest extends TestCase
public function testMaxPostSizeExceeded()
{
$serverParams = $this
- ->getMockBuilder('\Symfony\Component\Form\Util\ServerParams')
+ ->getMockBuilder(ServerParams::class)
->disableOriginalConstructor()
->getMock()
;
diff --git a/src/Symfony/Component/Form/Tests/Guess/GuessTest.php b/src/Symfony/Component/Form/Tests/Guess/GuessTest.php
index cc469f1b86..262e5d15e5 100644
--- a/src/Symfony/Component/Form/Tests/Guess/GuessTest.php
+++ b/src/Symfony/Component/Form/Tests/Guess/GuessTest.php
@@ -31,7 +31,7 @@ class GuessTest extends TestCase
public function testGuessExpectsValidConfidence()
{
- $this->expectException('\InvalidArgumentException');
+ $this->expectException(\InvalidArgumentException::class);
new TestGuess(5);
}
}
diff --git a/src/Symfony/Component/Form/Tests/ResolvedFormTypeTest.php b/src/Symfony/Component/Form/Tests/ResolvedFormTypeTest.php
index 4a1affd848..d024828d87 100644
--- a/src/Symfony/Component/Form/Tests/ResolvedFormTypeTest.php
+++ b/src/Symfony/Component/Form/Tests/ResolvedFormTypeTest.php
@@ -156,7 +156,7 @@ class ResolvedFormTypeTest extends TestCase
public function testCreateBuilderWithDataClassOption()
{
$givenOptions = ['data_class' => 'Foo'];
- $resolvedOptions = ['data_class' => '\stdClass'];
+ $resolvedOptions = ['data_class' => \stdClass::class];
$optionsResolver = $this->getMockBuilder('Symfony\Component\OptionsResolver\OptionsResolver')->getMock();
$this->resolvedType = $this->getMockBuilder('Symfony\Component\Form\ResolvedFormType')
@@ -178,7 +178,7 @@ class ResolvedFormTypeTest extends TestCase
$this->assertSame($this->resolvedType, $builder->getType());
$this->assertSame($resolvedOptions, $builder->getOptions());
- $this->assertSame('\stdClass', $builder->getDataClass());
+ $this->assertSame(\stdClass::class, $builder->getDataClass());
}
public function testFailsCreateBuilderOnInvalidFormOptionsResolution()
diff --git a/src/Symfony/Component/Form/Tests/SimpleFormTest.php b/src/Symfony/Component/Form/Tests/SimpleFormTest.php
index a74f8aa071..811ca4ef92 100644
--- a/src/Symfony/Component/Form/Tests/SimpleFormTest.php
+++ b/src/Symfony/Component/Form/Tests/SimpleFormTest.php
@@ -121,7 +121,7 @@ class SimpleFormTest extends AbstractFormTest
$preSetData = false;
$preSubmit = false;
- $mock = $this->getMockBuilder('\stdClass')
+ $mock = $this->getMockBuilder(\stdClass::class)
->setMethods(['preSetData', 'preSubmit'])
->getMock();
$mock->expects($this->once())
@@ -153,7 +153,7 @@ class SimpleFormTest extends AbstractFormTest
// https://github.com/symfony/symfony/pull/7789
public function testFalseIsConvertedToNull()
{
- $mock = $this->getMockBuilder('\stdClass')
+ $mock = $this->getMockBuilder(\stdClass::class)
->setMethods(['preSubmit'])
->getMock();
$mock->expects($this->once())
@@ -394,7 +394,7 @@ class SimpleFormTest extends AbstractFormTest
public function testSetDataClonesObjectIfNotByReference()
{
$data = new \stdClass();
- $form = $this->getBuilder('name', null, '\stdClass')->setByReference(false)->getForm();
+ $form = $this->getBuilder('name', null, \stdClass::class)->setByReference(false)->getForm();
$form->setData($data);
$this->assertNotSame($data, $form->getData());
@@ -404,7 +404,7 @@ class SimpleFormTest extends AbstractFormTest
public function testSetDataDoesNotCloneObjectIfByReference()
{
$data = new \stdClass();
- $form = $this->getBuilder('name', null, '\stdClass')->setByReference(true)->getForm();
+ $form = $this->getBuilder('name', null, \stdClass::class)->setByReference(true)->getForm();
$form->setData($data);
$this->assertSame($data, $form->getData());
diff --git a/src/Symfony/Component/HttpFoundation/Tests/Session/SessionTest.php b/src/Symfony/Component/HttpFoundation/Tests/Session/SessionTest.php
index e216bfc8c2..576a31b23b 100644
--- a/src/Symfony/Component/HttpFoundation/Tests/Session/SessionTest.php
+++ b/src/Symfony/Component/HttpFoundation/Tests/Session/SessionTest.php
@@ -89,7 +89,7 @@ class SessionTest extends TestCase
} catch (\Exception $e) {
}
- $this->assertInstanceOf('\LogicException', $e);
+ $this->assertInstanceOf(\LogicException::class, $e);
}
public function testSetName()
diff --git a/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/MemcachedSessionHandlerTest.php b/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/MemcachedSessionHandlerTest.php
index 6fe43a0027..0f8d8989b7 100644
--- a/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/MemcachedSessionHandlerTest.php
+++ b/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/MemcachedSessionHandlerTest.php
@@ -136,6 +136,6 @@ class MemcachedSessionHandlerTest extends TestCase
$method = new \ReflectionMethod($this->storage, 'getMemcached');
$method->setAccessible(true);
- $this->assertInstanceOf('\Memcached', $method->invoke($this->storage));
+ $this->assertInstanceOf(\Memcached::class, $method->invoke($this->storage));
}
}
diff --git a/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/PdoSessionHandlerTest.php b/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/PdoSessionHandlerTest.php
index 6042b88d27..f84c824e6d 100644
--- a/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/PdoSessionHandlerTest.php
+++ b/src/Symfony/Component/HttpFoundation/Tests/Session/Storage/Handler/PdoSessionHandlerTest.php
@@ -298,7 +298,7 @@ class PdoSessionHandlerTest extends TestCase
$method = new \ReflectionMethod($storage, 'getConnection');
$method->setAccessible(true);
- $this->assertInstanceOf('\PDO', $method->invoke($storage));
+ $this->assertInstanceOf(\PDO::class, $method->invoke($storage));
}
public function testGetConnectionConnectsIfNeeded()
@@ -308,7 +308,7 @@ class PdoSessionHandlerTest extends TestCase
$method = new \ReflectionMethod($storage, 'getConnection');
$method->setAccessible(true);
- $this->assertInstanceOf('\PDO', $method->invoke($storage));
+ $this->assertInstanceOf(\PDO::class, $method->invoke($storage));
}
/**
diff --git a/src/Symfony/Component/HttpKernel/Tests/Controller/ArgumentResolverTest.php b/src/Symfony/Component/HttpKernel/Tests/Controller/ArgumentResolverTest.php
index f2a726de39..c0ed800bb4 100644
--- a/src/Symfony/Component/HttpKernel/Tests/Controller/ArgumentResolverTest.php
+++ b/src/Symfony/Component/HttpKernel/Tests/Controller/ArgumentResolverTest.php
@@ -132,7 +132,7 @@ class ArgumentResolverTest extends TestCase
self::$resolver->getArguments($request, $controller);
$this->fail('->getArguments() throws a \RuntimeException exception if it cannot determine the argument value');
} catch (\Exception $e) {
- $this->assertInstanceOf('\RuntimeException', $e, '->getArguments() throws a \RuntimeException exception if it cannot determine the argument value');
+ $this->assertInstanceOf(\RuntimeException::class, $e, '->getArguments() throws a \RuntimeException exception if it cannot determine the argument value');
}
}
diff --git a/src/Symfony/Component/Intl/Intl.php b/src/Symfony/Component/Intl/Intl.php
index 08d586676b..dee7b4c622 100644
--- a/src/Symfony/Component/Intl/Intl.php
+++ b/src/Symfony/Component/Intl/Intl.php
@@ -111,7 +111,7 @@ final class Intl
*/
public static function isExtensionLoaded(): bool
{
- return class_exists('\ResourceBundle');
+ return class_exists(\ResourceBundle::class);
}
/**
diff --git a/src/Symfony/Component/Intl/Tests/Collator/CollatorTest.php b/src/Symfony/Component/Intl/Tests/Collator/CollatorTest.php
index 0964e31e34..70db01e7b7 100644
--- a/src/Symfony/Component/Intl/Tests/Collator/CollatorTest.php
+++ b/src/Symfony/Component/Intl/Tests/Collator/CollatorTest.php
@@ -12,6 +12,7 @@
namespace Symfony\Component\Intl\Tests\Collator;
use Symfony\Component\Intl\Collator\Collator;
+use Symfony\Component\Intl\Exception\MethodNotImplementedException;
use Symfony\Component\Intl\Globals\IntlGlobals;
class CollatorTest extends AbstractCollatorTest
@@ -57,19 +58,19 @@ class CollatorTest extends AbstractCollatorTest
public function testConstructWithoutLocale()
{
$collator = $this->getCollator(null);
- $this->assertInstanceOf('\Symfony\Component\Intl\Collator\Collator', $collator);
+ $this->assertInstanceOf(Collator::class, $collator);
}
public function testGetSortKey()
{
- $this->expectException('Symfony\Component\Intl\Exception\MethodNotImplementedException');
+ $this->expectException(MethodNotImplementedException::class);
$collator = $this->getCollator('en');
$collator->getSortKey('Hello');
}
public function testGetStrength()
{
- $this->expectException('Symfony\Component\Intl\Exception\MethodNotImplementedException');
+ $this->expectException(MethodNotImplementedException::class);
$collator = $this->getCollator('en');
$collator->getStrength();
}
@@ -92,7 +93,7 @@ class CollatorTest extends AbstractCollatorTest
{
$collator = $this->getCollator('en');
$collator = $collator::create('en');
- $this->assertInstanceOf('\Symfony\Component\Intl\Collator\Collator', $collator);
+ $this->assertInstanceOf(Collator::class, $collator);
}
protected function getCollator(?string $locale): Collator
diff --git a/src/Symfony/Component/Intl/Tests/Data/Bundle/Reader/IntlBundleReaderTest.php b/src/Symfony/Component/Intl/Tests/Data/Bundle/Reader/IntlBundleReaderTest.php
index 31f3ff2262..2272139616 100644
--- a/src/Symfony/Component/Intl/Tests/Data/Bundle/Reader/IntlBundleReaderTest.php
+++ b/src/Symfony/Component/Intl/Tests/Data/Bundle/Reader/IntlBundleReaderTest.php
@@ -34,7 +34,7 @@ class IntlBundleReaderTest extends TestCase
{
$data = $this->reader->read(__DIR__.'/Fixtures/res', 'ro');
- $this->assertInstanceOf('\ArrayAccess', $data);
+ $this->assertInstanceOf(\ArrayAccess::class, $data);
$this->assertSame('Bar', $data['Foo']);
$this->assertArrayNotHasKey('ExistsNot', $data);
}
@@ -44,7 +44,7 @@ class IntlBundleReaderTest extends TestCase
// "alias" = "ro"
$data = $this->reader->read(__DIR__.'/Fixtures/res', 'alias');
- $this->assertInstanceOf('\ArrayAccess', $data);
+ $this->assertInstanceOf(\ArrayAccess::class, $data);
$this->assertSame('Bar', $data['Foo']);
$this->assertArrayNotHasKey('ExistsNot', $data);
}
@@ -54,7 +54,7 @@ class IntlBundleReaderTest extends TestCase
// "ro_MD" -> "ro"
$data = $this->reader->read(__DIR__.'/Fixtures/res', 'ro_MD');
- $this->assertInstanceOf('\ArrayAccess', $data);
+ $this->assertInstanceOf(\ArrayAccess::class, $data);
$this->assertSame('Bam', $data['Baz']);
$this->assertArrayNotHasKey('Foo', $data);
$this->assertNull($data['Foo']);
diff --git a/src/Symfony/Component/Intl/Tests/DateFormatter/IntlDateFormatterTest.php b/src/Symfony/Component/Intl/Tests/DateFormatter/IntlDateFormatterTest.php
index f674c657ed..40b0efc227 100644
--- a/src/Symfony/Component/Intl/Tests/DateFormatter/IntlDateFormatterTest.php
+++ b/src/Symfony/Component/Intl/Tests/DateFormatter/IntlDateFormatterTest.php
@@ -44,7 +44,7 @@ class IntlDateFormatterTest extends AbstractIntlDateFormatterTest
{
$formatter = $this->getDateFormatter('en', IntlDateFormatter::MEDIUM, IntlDateFormatter::SHORT);
$formatter = $formatter::create('en', IntlDateFormatter::MEDIUM, IntlDateFormatter::SHORT);
- $this->assertInstanceOf('\Symfony\Component\Intl\DateFormatter\IntlDateFormatter', $formatter);
+ $this->assertInstanceOf(IntlDateFormatter::class, $formatter);
}
public function testFormatWithUnsupportedTimestampArgument()
diff --git a/src/Symfony/Component/Intl/Tests/NumberFormatter/NumberFormatterTest.php b/src/Symfony/Component/Intl/Tests/NumberFormatter/NumberFormatterTest.php
index 058e03756c..9e1f26d489 100644
--- a/src/Symfony/Component/Intl/Tests/NumberFormatter/NumberFormatterTest.php
+++ b/src/Symfony/Component/Intl/Tests/NumberFormatter/NumberFormatterTest.php
@@ -54,10 +54,7 @@ class NumberFormatterTest extends AbstractNumberFormatterTest
public function testConstructWithoutLocale()
{
- $this->assertInstanceOf(
- '\Symfony\Component\Intl\NumberFormatter\NumberFormatter',
- $this->getNumberFormatter(null, NumberFormatter::DECIMAL)
- );
+ $this->assertInstanceOf(NumberFormatter::class, $this->getNumberFormatter(null, NumberFormatter::DECIMAL));
}
public function testCreate()
diff --git a/src/Symfony/Component/Intl/Tests/NumberFormatter/Verification/NumberFormatterTest.php b/src/Symfony/Component/Intl/Tests/NumberFormatter/Verification/NumberFormatterTest.php
index edec2e9639..c062deaceb 100644
--- a/src/Symfony/Component/Intl/Tests/NumberFormatter/Verification/NumberFormatterTest.php
+++ b/src/Symfony/Component/Intl/Tests/NumberFormatter/Verification/NumberFormatterTest.php
@@ -29,7 +29,7 @@ class NumberFormatterTest extends AbstractNumberFormatterTest
public function testCreate()
{
- $this->assertInstanceOf('\NumberFormatter', \NumberFormatter::create('en', \NumberFormatter::DECIMAL));
+ $this->assertInstanceOf(\NumberFormatter::class, \NumberFormatter::create('en', \NumberFormatter::DECIMAL));
}
public function testGetTextAttribute()
diff --git a/src/Symfony/Component/Lock/Tests/Store/ExpiringStoreTestTrait.php b/src/Symfony/Component/Lock/Tests/Store/ExpiringStoreTestTrait.php
index 8b37bcfbc1..bf75d69c16 100644
--- a/src/Symfony/Component/Lock/Tests/Store/ExpiringStoreTestTrait.php
+++ b/src/Symfony/Component/Lock/Tests/Store/ExpiringStoreTestTrait.php
@@ -60,7 +60,7 @@ trait ExpiringStoreTestTrait
*/
public function testAbortAfterExpiration()
{
- $this->expectException('\Symfony\Component\Lock\Exception\LockExpiredException');
+ $this->expectException(LockExpiredException::class);
$key = new Key(uniqid(__METHOD__, true));
/** @var PersistingStoreInterface $store */
diff --git a/src/Symfony/Component/Mime/Tests/AbstractMimeTypeGuesserTest.php b/src/Symfony/Component/Mime/Tests/AbstractMimeTypeGuesserTest.php
index 7d5656054a..af1b97de98 100644
--- a/src/Symfony/Component/Mime/Tests/AbstractMimeTypeGuesserTest.php
+++ b/src/Symfony/Component/Mime/Tests/AbstractMimeTypeGuesserTest.php
@@ -57,7 +57,7 @@ abstract class AbstractMimeTypeGuesserTest extends TestCase
$this->markTestSkipped('Guesser is not supported');
}
- $this->expectException('\InvalidArgumentException');
+ $this->expectException(\InvalidArgumentException::class);
$this->getGuesser()->guessMimeType(__DIR__.'/Fixtures/mimetypes/directory');
}
@@ -94,7 +94,7 @@ abstract class AbstractMimeTypeGuesserTest extends TestCase
$this->markTestSkipped('Guesser is not supported');
}
- $this->expectException('\InvalidArgumentException');
+ $this->expectException(\InvalidArgumentException::class);
$this->getGuesser()->guessMimeType(__DIR__.'/Fixtures/mimetypes/not_here');
}
diff --git a/src/Symfony/Component/Routing/Tests/Matcher/Dumper/PhpMatcherDumperTest.php b/src/Symfony/Component/Routing/Tests/Matcher/Dumper/PhpMatcherDumperTest.php
index 6f7a610324..5665ebef37 100644
--- a/src/Symfony/Component/Routing/Tests/Matcher/Dumper/PhpMatcherDumperTest.php
+++ b/src/Symfony/Component/Routing/Tests/Matcher/Dumper/PhpMatcherDumperTest.php
@@ -480,7 +480,7 @@ class PhpMatcherDumperTest extends TestCase
$options = ['class' => $this->matcherClass];
if ($redirectableStub) {
- $options['base_class'] = '\Symfony\Component\Routing\Tests\Matcher\Dumper\RedirectableUrlMatcherStub';
+ $options['base_class'] = RedirectableUrlMatcherStub::class;
}
$dumper = new PhpMatcherDumper($collection);
diff --git a/src/Symfony/Component/Routing/Tests/RouteCollectionTest.php b/src/Symfony/Component/Routing/Tests/RouteCollectionTest.php
index f310d4e526..16b5868363 100644
--- a/src/Symfony/Component/Routing/Tests/RouteCollectionTest.php
+++ b/src/Symfony/Component/Routing/Tests/RouteCollectionTest.php
@@ -66,7 +66,7 @@ class RouteCollectionTest extends TestCase
$collection->addCollection($collection1);
$collection->add('last', $last = new Route('/last'));
- $this->assertInstanceOf('\ArrayIterator', $collection->getIterator());
+ $this->assertInstanceOf(\ArrayIterator::class, $collection->getIterator());
$this->assertSame(['bar' => $bar, 'foo' => $foo, 'last' => $last], $collection->getIterator()->getArrayCopy());
}
diff --git a/src/Symfony/Component/Routing/Tests/RouteTest.php b/src/Symfony/Component/Routing/Tests/RouteTest.php
index c02af42ce7..33341ea491 100644
--- a/src/Symfony/Component/Routing/Tests/RouteTest.php
+++ b/src/Symfony/Component/Routing/Tests/RouteTest.php
@@ -13,6 +13,8 @@ namespace Symfony\Component\Routing\Tests;
use PHPUnit\Framework\TestCase;
use Symfony\Component\Routing\Route;
+use Symfony\Component\Routing\Tests\Fixtures\CustomCompiledRoute;
+use Symfony\Component\Routing\Tests\Fixtures\CustomRouteCompiler;
class RouteTest extends TestCase
{
@@ -243,13 +245,13 @@ class RouteTest extends TestCase
*/
public function testSerializeWhenCompiledWithClass()
{
- $route = new Route('/', [], [], ['compiler_class' => '\Symfony\Component\Routing\Tests\Fixtures\CustomRouteCompiler']);
- $this->assertInstanceOf('\Symfony\Component\Routing\Tests\Fixtures\CustomCompiledRoute', $route->compile(), '->compile() returned a proper route');
+ $route = new Route('/', [], [], ['compiler_class' => CustomRouteCompiler::class]);
+ $this->assertInstanceOf(CustomCompiledRoute::class, $route->compile(), '->compile() returned a proper route');
$serialized = serialize($route);
try {
$unserialized = unserialize($serialized);
- $this->assertInstanceOf('\Symfony\Component\Routing\Tests\Fixtures\CustomCompiledRoute', $unserialized->compile(), 'the unserialized route compiled successfully');
+ $this->assertInstanceOf(CustomCompiledRoute::class, $unserialized->compile(), 'the unserialized route compiled successfully');
} catch (\Exception $e) {
$this->fail('unserializing a route which uses a custom compiled route class');
}
diff --git a/src/Symfony/Component/Security/Core/Tests/Authentication/Token/AbstractTokenTest.php b/src/Symfony/Component/Security/Core/Tests/Authentication/Token/AbstractTokenTest.php
index b61af1d6ba..3916d20337 100644
--- a/src/Symfony/Component/Security/Core/Tests/Authentication/Token/AbstractTokenTest.php
+++ b/src/Symfony/Component/Security/Core/Tests/Authentication/Token/AbstractTokenTest.php
@@ -134,7 +134,7 @@ class AbstractTokenTest extends TestCase
$token->getAttribute('foobar');
$this->fail('->getAttribute() throws an \InvalidArgumentException exception when the attribute does not exist');
} catch (\Exception $e) {
- $this->assertInstanceOf('\InvalidArgumentException', $e, '->getAttribute() throws an \InvalidArgumentException exception when the attribute does not exist');
+ $this->assertInstanceOf(\InvalidArgumentException::class, $e, '->getAttribute() throws an \InvalidArgumentException exception when the attribute does not exist');
$this->assertEquals('This token has no "foobar" attribute.', $e->getMessage(), '->getAttribute() throws an \InvalidArgumentException exception when the attribute does not exist');
}
}
diff --git a/src/Symfony/Component/Security/Http/Tests/Firewall/RememberMeListenerTest.php b/src/Symfony/Component/Security/Http/Tests/Firewall/RememberMeListenerTest.php
index 2dccec5b9a..cf46161032 100644
--- a/src/Symfony/Component/Security/Http/Tests/Firewall/RememberMeListenerTest.php
+++ b/src/Symfony/Component/Security/Http/Tests/Firewall/RememberMeListenerTest.php
@@ -13,12 +13,14 @@ namespace Symfony\Component\Security\Http\Tests\Firewall;
use PHPUnit\Framework\TestCase;
use Symfony\Component\HttpFoundation\Request;
+use Symfony\Component\HttpFoundation\Session\SessionInterface;
use Symfony\Component\HttpKernel\Event\RequestEvent;
use Symfony\Component\HttpKernel\Event\ResponseEvent;
use Symfony\Component\HttpKernel\HttpKernelInterface;
use Symfony\Component\Security\Core\Exception\AuthenticationException;
use Symfony\Component\Security\Http\Firewall\RememberMeListener;
use Symfony\Component\Security\Http\SecurityEvents;
+use Symfony\Component\Security\Http\Session\SessionAuthenticationStrategyInterface;
use Symfony\Contracts\EventDispatcher\EventDispatcherInterface;
class RememberMeListenerTest extends TestCase
@@ -227,7 +229,7 @@ class RememberMeListenerTest extends TestCase
->willReturn($token)
;
- $session = $this->getMockBuilder('\Symfony\Component\HttpFoundation\Session\SessionInterface')->getMock();
+ $session = $this->getMockBuilder(SessionInterface::class)->getMock();
$session
->expects($this->once())
->method('isStarted')
@@ -277,7 +279,7 @@ class RememberMeListenerTest extends TestCase
->willReturn($token)
;
- $session = $this->getMockBuilder('\Symfony\Component\HttpFoundation\Session\SessionInterface')->getMock();
+ $session = $this->getMockBuilder(SessionInterface::class)->getMock();
$session
->expects($this->once())
->method('isStarted')
@@ -402,6 +404,6 @@ class RememberMeListenerTest extends TestCase
private function getSessionStrategy()
{
- return $this->getMockBuilder('\Symfony\Component\Security\Http\Session\SessionAuthenticationStrategyInterface')->getMock();
+ return $this->getMockBuilder(SessionAuthenticationStrategyInterface::class)->getMock();
}
}
diff --git a/src/Symfony/Component/Serializer/Tests/Encoder/XmlEncoderTest.php b/src/Symfony/Component/Serializer/Tests/Encoder/XmlEncoderTest.php
index 592ac702bd..a26f876918 100644
--- a/src/Symfony/Component/Serializer/Tests/Encoder/XmlEncoderTest.php
+++ b/src/Symfony/Component/Serializer/Tests/Encoder/XmlEncoderTest.php
@@ -934,7 +934,7 @@ XML;
*/
private function createMockDateTimeNormalizer()
{
- $mock = $this->getMockBuilder('\Symfony\Component\Serializer\Normalizer\CustomNormalizer')->getMock();
+ $mock = $this->getMockBuilder(CustomNormalizer::class)->getMock();
$mock
->expects($this->once())
diff --git a/src/Symfony/Component/Serializer/Tests/SerializerTest.php b/src/Symfony/Component/Serializer/Tests/SerializerTest.php
index 9ddeb3adb8..cde5fc0665 100644
--- a/src/Symfony/Component/Serializer/Tests/SerializerTest.php
+++ b/src/Symfony/Component/Serializer/Tests/SerializerTest.php
@@ -231,7 +231,7 @@ class SerializerTest extends TestCase
{
$serializer = new Serializer([new GetSetMethodNormalizer()], ['json' => new JsonEncoder()]);
$data = ['title' => 'foo', 'numbers' => [5, 3]];
- $result = $serializer->deserialize(json_encode($data), '\Symfony\Component\Serializer\Tests\Model', 'json');
+ $result = $serializer->deserialize(json_encode($data), Model::class, 'json');
$this->assertEquals($data, $result->toArray());
}
@@ -239,9 +239,9 @@ class SerializerTest extends TestCase
{
$serializer = new Serializer([new GetSetMethodNormalizer()], ['json' => new JsonEncoder()]);
$data = ['title' => 'foo', 'numbers' => [5, 3]];
- $serializer->deserialize(json_encode($data), '\Symfony\Component\Serializer\Tests\Model', 'json');
+ $serializer->deserialize(json_encode($data), Model::class, 'json');
$data = ['title' => 'bar', 'numbers' => [2, 8]];
- $result = $serializer->deserialize(json_encode($data), '\Symfony\Component\Serializer\Tests\Model', 'json');
+ $result = $serializer->deserialize(json_encode($data), Model::class, 'json');
$this->assertEquals($data, $result->toArray());
}
@@ -250,7 +250,7 @@ class SerializerTest extends TestCase
$this->expectException('Symfony\Component\Serializer\Exception\LogicException');
$serializer = new Serializer([], ['json' => new JsonEncoder()]);
$data = ['title' => 'foo', 'numbers' => [5, 3]];
- $serializer->deserialize(json_encode($data), '\Symfony\Component\Serializer\Tests\Model', 'json');
+ $serializer->deserialize(json_encode($data), Model::class, 'json');
}
public function testDeserializeWrongNormalizer()
@@ -258,7 +258,7 @@ class SerializerTest extends TestCase
$this->expectException('Symfony\Component\Serializer\Exception\UnexpectedValueException');
$serializer = new Serializer([new CustomNormalizer()], ['json' => new JsonEncoder()]);
$data = ['title' => 'foo', 'numbers' => [5, 3]];
- $serializer->deserialize(json_encode($data), '\Symfony\Component\Serializer\Tests\Model', 'json');
+ $serializer->deserialize(json_encode($data), Model::class, 'json');
}
public function testDeserializeNoEncoder()
@@ -266,14 +266,14 @@ class SerializerTest extends TestCase
$this->expectException('Symfony\Component\Serializer\Exception\UnexpectedValueException');
$serializer = new Serializer([], []);
$data = ['title' => 'foo', 'numbers' => [5, 3]];
- $serializer->deserialize(json_encode($data), '\Symfony\Component\Serializer\Tests\Model', 'json');
+ $serializer->deserialize(json_encode($data), Model::class, 'json');
}
public function testDeserializeSupported()
{
$serializer = new Serializer([new GetSetMethodNormalizer()], []);
$data = ['title' => 'foo', 'numbers' => [5, 3]];
- $this->assertTrue($serializer->supportsDenormalization(json_encode($data), '\Symfony\Component\Serializer\Tests\Model', 'json'));
+ $this->assertTrue($serializer->supportsDenormalization(json_encode($data), Model::class, 'json'));
}
public function testDeserializeNotSupported()
@@ -287,7 +287,7 @@ class SerializerTest extends TestCase
{
$serializer = new Serializer([], []);
$data = ['title' => 'foo', 'numbers' => [5, 3]];
- $this->assertFalse($serializer->supportsDenormalization(json_encode($data), '\Symfony\Component\Serializer\Tests\Model', 'json'));
+ $this->assertFalse($serializer->supportsDenormalization(json_encode($data), Model::class, 'json'));
}
public function testEncode()
diff --git a/src/Symfony/Component/Templating/Tests/Helper/SlotsHelperTest.php b/src/Symfony/Component/Templating/Tests/Helper/SlotsHelperTest.php
index c747072c60..ad4e8ecfe2 100644
--- a/src/Symfony/Component/Templating/Tests/Helper/SlotsHelperTest.php
+++ b/src/Symfony/Component/Templating/Tests/Helper/SlotsHelperTest.php
@@ -66,7 +66,7 @@ class SlotsHelperTest extends TestCase
$this->fail('->start() throws an InvalidArgumentException if a slot with the same name is already started');
} catch (\Exception $e) {
$helper->stop();
- $this->assertInstanceOf('\InvalidArgumentException', $e, '->start() throws an InvalidArgumentException if a slot with the same name is already started');
+ $this->assertInstanceOf(\InvalidArgumentException::class, $e, '->start() throws an InvalidArgumentException if a slot with the same name is already started');
$this->assertEquals('A slot named "bar" is already started.', $e->getMessage(), '->start() throws an InvalidArgumentException if a slot with the same name is already started');
}
@@ -74,7 +74,7 @@ class SlotsHelperTest extends TestCase
$helper->stop();
$this->fail('->stop() throws an LogicException if no slot is started');
} catch (\Exception $e) {
- $this->assertInstanceOf('\LogicException', $e, '->stop() throws an LogicException if no slot is started');
+ $this->assertInstanceOf(\LogicException::class, $e, '->stop() throws an LogicException if no slot is started');
$this->assertEquals('No slot started.', $e->getMessage(), '->stop() throws an LogicException if no slot is started');
}
}
diff --git a/src/Symfony/Component/Templating/Tests/PhpEngineTest.php b/src/Symfony/Component/Templating/Tests/PhpEngineTest.php
index 4e5d1bebe9..0de88516a6 100644
--- a/src/Symfony/Component/Templating/Tests/PhpEngineTest.php
+++ b/src/Symfony/Component/Templating/Tests/PhpEngineTest.php
@@ -51,7 +51,7 @@ class PhpEngineTest extends TestCase
$engine['bar'];
$this->fail('->offsetGet() throws an InvalidArgumentException if the helper is not defined');
} catch (\Exception $e) {
- $this->assertInstanceOf('\InvalidArgumentException', $e, '->offsetGet() throws an InvalidArgumentException if the helper is not defined');
+ $this->assertInstanceOf(\InvalidArgumentException::class, $e, '->offsetGet() throws an InvalidArgumentException if the helper is not defined');
$this->assertEquals('The helper "bar" is not defined.', $e->getMessage(), '->offsetGet() throws an InvalidArgumentException if the helper is not defined');
}
}
@@ -72,7 +72,7 @@ class PhpEngineTest extends TestCase
$engine->get('foobar');
$this->fail('->get() throws an InvalidArgumentException if the helper is not defined');
} catch (\Exception $e) {
- $this->assertInstanceOf('\InvalidArgumentException', $e, '->get() throws an InvalidArgumentException if the helper is not defined');
+ $this->assertInstanceOf(\InvalidArgumentException::class, $e, '->get() throws an InvalidArgumentException if the helper is not defined');
$this->assertEquals('The helper "foobar" is not defined.', $e->getMessage(), '->get() throws an InvalidArgumentException if the helper is not defined');
}
@@ -87,7 +87,7 @@ class PhpEngineTest extends TestCase
$foo = new \Symfony\Component\Templating\Tests\Fixtures\SimpleHelper('foo');
$engine->set($foo);
- $this->expectException('\LogicException');
+ $this->expectException(\LogicException::class);
unset($engine['foo']);
}
@@ -99,7 +99,7 @@ class PhpEngineTest extends TestCase
$engine->render('name');
$this->fail('->render() throws an InvalidArgumentException if the template does not exist');
} catch (\Exception $e) {
- $this->assertInstanceOf('\InvalidArgumentException', $e, '->render() throws an InvalidArgumentException if the template does not exist');
+ $this->assertInstanceOf(\InvalidArgumentException::class, $e, '->render() throws an InvalidArgumentException if the template does not exist');
$this->assertEquals('The template "name" does not exist.', $e->getMessage(), '->render() throws an InvalidArgumentException if the template does not exist');
}
diff --git a/src/Symfony/Component/Validator/Constraints/EmailValidator.php b/src/Symfony/Component/Validator/Constraints/EmailValidator.php
index 5c37b5e8ad..4642f41b67 100644
--- a/src/Symfony/Component/Validator/Constraints/EmailValidator.php
+++ b/src/Symfony/Component/Validator/Constraints/EmailValidator.php
@@ -11,6 +11,7 @@
namespace Symfony\Component\Validator\Constraints;
+use Egulias\EmailValidator\EmailValidator as EguliasEmailValidator;
use Egulias\EmailValidator\Validation\EmailValidation;
use Egulias\EmailValidator\Validation\NoRFCWarningsValidation;
use Symfony\Component\Validator\Constraint;
@@ -107,11 +108,11 @@ class EmailValidator extends ConstraintValidator
}
if (Email::VALIDATION_MODE_STRICT === $constraint->mode) {
- if (!class_exists('\Egulias\EmailValidator\EmailValidator')) {
+ if (!class_exists(EguliasEmailValidator::class)) {
throw new LogicException('Strict email validation requires egulias/email-validator ~1.2|~2.0.');
}
- $strictValidator = new \Egulias\EmailValidator\EmailValidator();
+ $strictValidator = new EguliasEmailValidator();
if (interface_exists(EmailValidation::class) && !$strictValidator->isValid($value, new NoRFCWarningsValidation())) {
$this->context->buildViolation($constraint->message)
diff --git a/src/Symfony/Component/Validator/Tests/Mapping/Loader/XmlFileLoaderTest.php b/src/Symfony/Component/Validator/Tests/Mapping/Loader/XmlFileLoaderTest.php
index 53c77ec338..aedf13ec39 100644
--- a/src/Symfony/Component/Validator/Tests/Mapping/Loader/XmlFileLoaderTest.php
+++ b/src/Symfony/Component/Validator/Tests/Mapping/Loader/XmlFileLoaderTest.php
@@ -114,7 +114,7 @@ class XmlFileLoaderTest extends TestCase
$loader = new XmlFileLoader(__DIR__.'/withdoctype.xml');
$metadata = new ClassMetadata('Symfony\Component\Validator\Tests\Fixtures\Entity');
- $this->expectException('\Symfony\Component\Validator\Exception\MappingException');
+ $this->expectException(MappingException::class);
$loader->loadClassMetadata($metadata);
}
@@ -129,7 +129,7 @@ class XmlFileLoaderTest extends TestCase
try {
$loader->loadClassMetadata($metadata);
} catch (MappingException $e) {
- $this->expectException('\Symfony\Component\Validator\Exception\MappingException');
+ $this->expectException(MappingException::class);
$loader->loadClassMetadata($metadata);
}
}
diff --git a/src/Symfony/Component/Validator/Tests/Mapping/Loader/YamlFileLoaderTest.php b/src/Symfony/Component/Validator/Tests/Mapping/Loader/YamlFileLoaderTest.php
index 57033884d7..1da3f234c9 100644
--- a/src/Symfony/Component/Validator/Tests/Mapping/Loader/YamlFileLoaderTest.php
+++ b/src/Symfony/Component/Validator/Tests/Mapping/Loader/YamlFileLoaderTest.php
@@ -69,7 +69,7 @@ class YamlFileLoaderTest extends TestCase
$loader->loadClassMetadata($metadata);
} catch (\InvalidArgumentException $e) {
// Call again. Again an exception should be thrown
- $this->expectException('\InvalidArgumentException');
+ $this->expectException(\InvalidArgumentException::class);
$loader->loadClassMetadata($metadata);
}
}
@@ -85,7 +85,7 @@ class YamlFileLoaderTest extends TestCase
public function testLoadClassMetadataReturnsFalseIfNotSuccessful()
{
$loader = new YamlFileLoader(__DIR__.'/constraint-mapping.yml');
- $metadata = new ClassMetadata('\stdClass');
+ $metadata = new ClassMetadata(\stdClass::class);
$this->assertFalse($loader->loadClassMetadata($metadata));
}
diff --git a/src/Symfony/Component/Yaml/Tests/ParserTest.php b/src/Symfony/Component/Yaml/Tests/ParserTest.php
index 187ed17ea2..fa5ecfa37a 100644
--- a/src/Symfony/Component/Yaml/Tests/ParserTest.php
+++ b/src/Symfony/Component/Yaml/Tests/ParserTest.php
@@ -68,7 +68,7 @@ class ParserTest extends TestCase
$this->fail('YAML files must not contain tabs');
} catch (\Exception $e) {
- $this->assertInstanceOf('\Exception', $e, 'YAML files must not contain tabs');
+ $this->assertInstanceOf(\Exception::class, $e, 'YAML files must not contain tabs');
$this->assertEquals('A YAML file cannot contain tabs as indentation at line 2 (near "'.strpbrk($yaml, "\t").'").', $e->getMessage(), 'YAML files must not contain tabs');
}
}
@@ -1415,7 +1415,7 @@ EOT;
*/
public function testParserThrowsExceptionWithCorrectLineNumber($lineNumber, $yaml)
{
- $this->expectException('\Symfony\Component\Yaml\Exception\ParseException');
+ $this->expectException(ParseException::class);
$this->expectExceptionMessage(sprintf('Unexpected characters near "," at line %d (near "bar: "123",").', $lineNumber));
$this->parser->parse($yaml);