From ba24bca384f2f39d00651f96cae27c7316cbc360 Mon Sep 17 00:00:00 2001 From: Fabien Potencier Date: Mon, 11 Jan 2021 07:14:03 +0100 Subject: [PATCH] Use ::class keyword when possible --- .../Component/Form/Extension/Core/Type/ChoiceType.php | 2 +- .../ChoiceList/Factory/PropertyAccessDecoratorTest.php | 6 +++--- src/Symfony/Component/Form/Tests/CompoundFormTest.php | 9 +++++---- src/Symfony/Component/Form/Tests/SimpleFormTest.php | 2 +- .../Tests/Data/Bundle/Reader/IntlBundleReaderTest.php | 2 +- .../Component/Mime/Tests/AbstractMimeTypeGuesserTest.php | 2 +- 6 files changed, 12 insertions(+), 11 deletions(-) diff --git a/src/Symfony/Component/Form/Extension/Core/Type/ChoiceType.php b/src/Symfony/Component/Form/Extension/Core/Type/ChoiceType.php index e463e158c6..fcb2969e2e 100644 --- a/src/Symfony/Component/Form/Extension/Core/Type/ChoiceType.php +++ b/src/Symfony/Component/Form/Extension/Core/Type/ChoiceType.php @@ -352,7 +352,7 @@ class ChoiceType extends AbstractType $resolver->setAllowedTypes('choice_name', ['null', 'callable', 'string', PropertyPath::class, ChoiceFieldName::class]); $resolver->setAllowedTypes('choice_value', ['null', 'callable', 'string', PropertyPath::class, ChoiceValue::class]); $resolver->setAllowedTypes('choice_attr', ['null', 'array', 'callable', 'string', PropertyPath::class, ChoiceAttr::class]); - $resolver->setAllowedTypes('preferred_choices', ['array', '\Traversable', 'callable', 'string', PropertyPath::class, PreferredChoice::class]); + $resolver->setAllowedTypes('preferred_choices', ['array', \Traversable::class, 'callable', 'string', PropertyPath::class, PreferredChoice::class]); $resolver->setAllowedTypes('group_by', ['null', 'callable', 'string', PropertyPath::class, GroupBy::class]); } diff --git a/src/Symfony/Component/Form/Tests/ChoiceList/Factory/PropertyAccessDecoratorTest.php b/src/Symfony/Component/Form/Tests/ChoiceList/Factory/PropertyAccessDecoratorTest.php index 77a67c5e22..e94261cd57 100644 --- a/src/Symfony/Component/Form/Tests/ChoiceList/Factory/PropertyAccessDecoratorTest.php +++ b/src/Symfony/Component/Form/Tests/ChoiceList/Factory/PropertyAccessDecoratorTest.php @@ -78,7 +78,7 @@ class PropertyAccessDecoratorTest extends TestCase $this->decoratedFactory->expects($this->once()) ->method('createListFromChoices') - ->with($choices, $this->isInstanceOf('\Closure'), $this->isInstanceOf('\Closure')) + ->with($choices, $this->isInstanceOf(\Closure::class), $this->isInstanceOf(\Closure::class)) ->willReturnCallback(function ($choices, $value, $callback) { return new ArrayChoiceList(array_map($value, array_filter($choices, $callback))); }); @@ -97,7 +97,7 @@ class PropertyAccessDecoratorTest extends TestCase $this->decoratedFactory->expects($this->once()) ->method('createListFromChoices') - ->with($choices, $this->isInstanceOf('\Closure'), $this->isInstanceOf('\Closure')) + ->with($choices, $this->isInstanceOf(\Closure::class), $this->isInstanceOf(\Closure::class)) ->willReturnCallback(function ($choices, $value, $callback) { return new ArrayChoiceList(array_map($value, array_filter($choices, $callback))); }); @@ -134,7 +134,7 @@ class PropertyAccessDecoratorTest extends TestCase $this->decoratedFactory->expects($this->once()) ->method('createListFromLoader') - ->with($loader, $this->isInstanceOf('\Closure'), $this->isInstanceOf('\Closure')) + ->with($loader, $this->isInstanceOf(\Closure::class), $this->isInstanceOf(\Closure::class)) ->willReturnCallback(function ($loader, $value, $callback) use ($choices) { return new ArrayChoiceList(array_map($value, array_filter($choices, $callback))); }); diff --git a/src/Symfony/Component/Form/Tests/CompoundFormTest.php b/src/Symfony/Component/Form/Tests/CompoundFormTest.php index c586aaebf6..5848d9dd1c 100644 --- a/src/Symfony/Component/Form/Tests/CompoundFormTest.php +++ b/src/Symfony/Component/Form/Tests/CompoundFormTest.php @@ -22,6 +22,7 @@ use Symfony\Component\Form\Forms; use Symfony\Component\Form\FormView; use Symfony\Component\Form\SubmitButtonBuilder; use Symfony\Component\Form\Tests\Fixtures\FixedDataTransformer; +use Symfony\Component\Form\Util\InheritDataAwareIterator; use Symfony\Component\HttpFoundation\File\UploadedFile; use Symfony\Component\HttpFoundation\Request; @@ -513,9 +514,9 @@ class CompoundFormTest extends AbstractFormTest $mapper->expects($this->once()) ->method('mapFormsToData') - ->with($this->isInstanceOf('\RecursiveIteratorIterator'), 'bar') + ->with($this->isInstanceOf(\RecursiveIteratorIterator::class), 'bar') ->willReturnCallback(function (\RecursiveIteratorIterator $iterator) use ($child1, $child2) { - $this->assertInstanceOf('Symfony\Component\Form\Util\InheritDataAwareIterator', $iterator->getInnerIterator()); + $this->assertInstanceOf(InheritDataAwareIterator::class, $iterator->getInnerIterator()); $this->assertSame(['firstName' => $child1, 'lastName' => $child2], iterator_to_array($iterator)); $this->assertEquals('Bernhard', $child1->getData()); $this->assertEquals('Schussek', $child2->getData()); @@ -585,9 +586,9 @@ class CompoundFormTest extends AbstractFormTest $mapper->expects($this->once()) ->method('mapFormsToData') - ->with($this->isInstanceOf('\RecursiveIteratorIterator'), $object) + ->with($this->isInstanceOf(\RecursiveIteratorIterator::class), $object) ->willReturnCallback(function (\RecursiveIteratorIterator $iterator) use ($child) { - $this->assertInstanceOf('Symfony\Component\Form\Util\InheritDataAwareIterator', $iterator->getInnerIterator()); + $this->assertInstanceOf(InheritDataAwareIterator::class, $iterator->getInnerIterator()); $this->assertSame(['name' => $child], iterator_to_array($iterator)); }); diff --git a/src/Symfony/Component/Form/Tests/SimpleFormTest.php b/src/Symfony/Component/Form/Tests/SimpleFormTest.php index d2d4a2f559..744198f95f 100644 --- a/src/Symfony/Component/Form/Tests/SimpleFormTest.php +++ b/src/Symfony/Component/Form/Tests/SimpleFormTest.php @@ -882,7 +882,7 @@ class SimpleFormTest extends AbstractFormTest public function testViewDataMayBeArrayAccessIfDataClassIsNull() { - $arrayAccess = $this->getMockBuilder('\ArrayAccess')->getMock(); + $arrayAccess = $this->getMockBuilder(\ArrayAccess::class)->getMock(); $config = new FormConfigBuilder('name', null, $this->dispatcher); $config->addViewTransformer(new FixedDataTransformer([ '' => '', 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 2272139616..24ac5ee1af 100644 --- a/src/Symfony/Component/Intl/Tests/Data/Bundle/Reader/IntlBundleReaderTest.php +++ b/src/Symfony/Component/Intl/Tests/Data/Bundle/Reader/IntlBundleReaderTest.php @@ -66,7 +66,7 @@ class IntlBundleReaderTest extends TestCase // "mo" = "ro_MD" -> "ro" $data = $this->reader->read(__DIR__.'/Fixtures/res', 'mo'); - $this->assertInstanceOf('\ArrayAccess', $data); + $this->assertInstanceOf(\ArrayAccess::class, $data); $this->assertSame('Bam', $data['Baz'], 'data from the aliased locale can be accessed'); $this->assertArrayNotHasKey('Foo', $data); $this->assertNull($data['Foo']); diff --git a/src/Symfony/Component/Mime/Tests/AbstractMimeTypeGuesserTest.php b/src/Symfony/Component/Mime/Tests/AbstractMimeTypeGuesserTest.php index af1b97de98..093358c3f8 100644 --- a/src/Symfony/Component/Mime/Tests/AbstractMimeTypeGuesserTest.php +++ b/src/Symfony/Component/Mime/Tests/AbstractMimeTypeGuesserTest.php @@ -117,7 +117,7 @@ abstract class AbstractMimeTypeGuesserTest extends TestCase @chmod($path, 0333); if ('0333' == substr(sprintf('%o', fileperms($path)), -4)) { - $this->expectException('\InvalidArgumentException'); + $this->expectException(\InvalidArgumentException::class); $this->getGuesser()->guessMimeType($path); } else { $this->markTestSkipped('Can not verify chmod operations, change of file permissions failed');