Use ::class keyword when possible

This commit is contained in:
Fabien Potencier 2021-01-11 07:14:03 +01:00
parent 589ab8b8fc
commit ba24bca384
6 changed files with 12 additions and 11 deletions

View File

@ -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]);
}

View File

@ -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)));
});

View File

@ -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));
});

View File

@ -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([
'' => '',

View File

@ -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']);

View File

@ -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');