Skip to content

Commit 84a6be3

Browse files
committed
Use ::class keyword when possible
1 parent d2ea292 commit 84a6be3

14 files changed

+87
-87
lines changed

Tests/ChoiceList/Factory/CachingFactoryDecoratorTest.php

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ class CachingFactoryDecoratorTest extends TestCase
3838

3939
protected function setUp(): void
4040
{
41-
$this->decoratedFactory = $this->getMockBuilder('Symfony\Component\Form\ChoiceList\Factory\ChoiceListFactoryInterface')->getMock();
41+
$this->decoratedFactory = $this->getMockBuilder(\Symfony\Component\Form\ChoiceList\Factory\ChoiceListFactoryInterface::class)->getMock();
4242
$this->factory = new CachingFactoryDecorator($this->decoratedFactory);
4343
}
4444

@@ -238,7 +238,7 @@ public function testCreateFromChoicesDifferentFilterClosure()
238238

239239
public function testCreateFromLoaderSameLoader()
240240
{
241-
$loader = $this->getMockBuilder('Symfony\Component\Form\ChoiceList\Loader\ChoiceLoaderInterface')->getMock();
241+
$loader = $this->getMockBuilder(ChoiceLoaderInterface::class)->getMock();
242242
$list = new ArrayChoiceList([]);
243243
$list2 = new ArrayChoiceList([]);
244244

@@ -269,8 +269,8 @@ public function testCreateFromLoaderSameLoaderUseCache()
269269

270270
public function testCreateFromLoaderDifferentLoader()
271271
{
272-
$loader1 = $this->getMockBuilder('Symfony\Component\Form\ChoiceList\Loader\ChoiceLoaderInterface')->getMock();
273-
$loader2 = $this->getMockBuilder('Symfony\Component\Form\ChoiceList\Loader\ChoiceLoaderInterface')->getMock();
272+
$loader1 = $this->getMockBuilder(ChoiceLoaderInterface::class)->getMock();
273+
$loader2 = $this->getMockBuilder(ChoiceLoaderInterface::class)->getMock();
274274
$list1 = new ArrayChoiceList([]);
275275
$list2 = new ArrayChoiceList([]);
276276

@@ -288,7 +288,7 @@ public function testCreateFromLoaderDifferentLoader()
288288

289289
public function testCreateFromLoaderSameValueClosure()
290290
{
291-
$loader = $this->getMockBuilder('Symfony\Component\Form\ChoiceList\Loader\ChoiceLoaderInterface')->getMock();
291+
$loader = $this->getMockBuilder(ChoiceLoaderInterface::class)->getMock();
292292
$type = $this->createMock(FormTypeInterface::class);
293293
$list = new ArrayChoiceList([]);
294294
$list2 = new ArrayChoiceList([]);
@@ -328,7 +328,7 @@ public function testCreateFromLoaderSameValueClosureUseCache()
328328

329329
public function testCreateFromLoaderDifferentValueClosure()
330330
{
331-
$loader = $this->getMockBuilder('Symfony\Component\Form\ChoiceList\Loader\ChoiceLoaderInterface')->getMock();
331+
$loader = $this->getMockBuilder(ChoiceLoaderInterface::class)->getMock();
332332
$type = $this->createMock(FormTypeInterface::class);
333333
$list1 = new ArrayChoiceList([]);
334334
$list2 = new ArrayChoiceList([]);
@@ -349,7 +349,7 @@ public function testCreateFromLoaderDifferentValueClosure()
349349

350350
public function testCreateFromLoaderSameFilterClosure()
351351
{
352-
$loader = $this->getMockBuilder('Symfony\Component\Form\ChoiceList\Loader\ChoiceLoaderInterface')->getMock();
352+
$loader = $this->getMockBuilder(ChoiceLoaderInterface::class)->getMock();
353353
$type = $this->createMock(FormTypeInterface::class);
354354
$list = new ArrayChoiceList([]);
355355
$list2 = new ArrayChoiceList([]);
@@ -391,7 +391,7 @@ public function testCreateFromLoaderSameFilterClosureUseCache()
391391

392392
public function testCreateFromLoaderDifferentFilterClosure()
393393
{
394-
$loader = $this->getMockBuilder('Symfony\Component\Form\ChoiceList\Loader\ChoiceLoaderInterface')->getMock();
394+
$loader = $this->getMockBuilder(ChoiceLoaderInterface::class)->getMock();
395395
$type = $this->createMock(FormTypeInterface::class);
396396
$list1 = new ArrayChoiceList([]);
397397
$list2 = new ArrayChoiceList([]);
@@ -413,7 +413,7 @@ public function testCreateFromLoaderDifferentFilterClosure()
413413
public function testCreateViewSamePreferredChoices()
414414
{
415415
$preferred = ['a'];
416-
$list = $this->getMockBuilder('Symfony\Component\Form\ChoiceList\ChoiceListInterface')->getMock();
416+
$list = $this->getMockBuilder(ChoiceListInterface::class)->getMock();
417417
$view = new ChoiceListView();
418418
$view2 = new ChoiceListView();
419419

@@ -447,7 +447,7 @@ public function testCreateViewDifferentPreferredChoices()
447447
{
448448
$preferred1 = ['a'];
449449
$preferred2 = ['b'];
450-
$list = $this->getMockBuilder('Symfony\Component\Form\ChoiceList\ChoiceListInterface')->getMock();
450+
$list = $this->getMockBuilder(ChoiceListInterface::class)->getMock();
451451
$view1 = new ChoiceListView();
452452
$view2 = new ChoiceListView();
453453

@@ -466,7 +466,7 @@ public function testCreateViewDifferentPreferredChoices()
466466
public function testCreateViewSamePreferredChoicesClosure()
467467
{
468468
$preferred = function () {};
469-
$list = $this->getMockBuilder('Symfony\Component\Form\ChoiceList\ChoiceListInterface')->getMock();
469+
$list = $this->getMockBuilder(ChoiceListInterface::class)->getMock();
470470
$view = new ChoiceListView();
471471
$view2 = new ChoiceListView();
472472

@@ -500,7 +500,7 @@ public function testCreateViewDifferentPreferredChoicesClosure()
500500
{
501501
$preferred1 = function () {};
502502
$preferred2 = function () {};
503-
$list = $this->getMockBuilder('Symfony\Component\Form\ChoiceList\ChoiceListInterface')->getMock();
503+
$list = $this->getMockBuilder(ChoiceListInterface::class)->getMock();
504504
$view1 = new ChoiceListView();
505505
$view2 = new ChoiceListView();
506506

@@ -519,7 +519,7 @@ public function testCreateViewDifferentPreferredChoicesClosure()
519519
public function testCreateViewSameLabelClosure()
520520
{
521521
$labels = function () {};
522-
$list = $this->getMockBuilder('Symfony\Component\Form\ChoiceList\ChoiceListInterface')->getMock();
522+
$list = $this->getMockBuilder(ChoiceListInterface::class)->getMock();
523523
$view = new ChoiceListView();
524524
$view2 = new ChoiceListView();
525525

@@ -553,7 +553,7 @@ public function testCreateViewDifferentLabelClosure()
553553
{
554554
$labels1 = function () {};
555555
$labels2 = function () {};
556-
$list = $this->getMockBuilder('Symfony\Component\Form\ChoiceList\ChoiceListInterface')->getMock();
556+
$list = $this->getMockBuilder(ChoiceListInterface::class)->getMock();
557557
$view1 = new ChoiceListView();
558558
$view2 = new ChoiceListView();
559559

@@ -572,7 +572,7 @@ public function testCreateViewDifferentLabelClosure()
572572
public function testCreateViewSameIndexClosure()
573573
{
574574
$index = function () {};
575-
$list = $this->getMockBuilder('Symfony\Component\Form\ChoiceList\ChoiceListInterface')->getMock();
575+
$list = $this->getMockBuilder(ChoiceListInterface::class)->getMock();
576576
$view = new ChoiceListView();
577577
$view2 = new ChoiceListView();
578578

@@ -606,7 +606,7 @@ public function testCreateViewDifferentIndexClosure()
606606
{
607607
$index1 = function () {};
608608
$index2 = function () {};
609-
$list = $this->getMockBuilder('Symfony\Component\Form\ChoiceList\ChoiceListInterface')->getMock();
609+
$list = $this->getMockBuilder(ChoiceListInterface::class)->getMock();
610610
$view1 = new ChoiceListView();
611611
$view2 = new ChoiceListView();
612612

@@ -625,7 +625,7 @@ public function testCreateViewDifferentIndexClosure()
625625
public function testCreateViewSameGroupByClosure()
626626
{
627627
$groupBy = function () {};
628-
$list = $this->getMockBuilder('Symfony\Component\Form\ChoiceList\ChoiceListInterface')->getMock();
628+
$list = $this->getMockBuilder(ChoiceListInterface::class)->getMock();
629629
$view = new ChoiceListView();
630630
$view2 = new ChoiceListView();
631631

@@ -659,7 +659,7 @@ public function testCreateViewDifferentGroupByClosure()
659659
{
660660
$groupBy1 = function () {};
661661
$groupBy2 = function () {};
662-
$list = $this->getMockBuilder('Symfony\Component\Form\ChoiceList\ChoiceListInterface')->getMock();
662+
$list = $this->getMockBuilder(ChoiceListInterface::class)->getMock();
663663
$view1 = new ChoiceListView();
664664
$view2 = new ChoiceListView();
665665

@@ -678,7 +678,7 @@ public function testCreateViewDifferentGroupByClosure()
678678
public function testCreateViewSameAttributes()
679679
{
680680
$attr = ['class' => 'foobar'];
681-
$list = $this->getMockBuilder('Symfony\Component\Form\ChoiceList\ChoiceListInterface')->getMock();
681+
$list = $this->getMockBuilder(ChoiceListInterface::class)->getMock();
682682
$view = new ChoiceListView();
683683
$view2 = new ChoiceListView();
684684

@@ -711,7 +711,7 @@ public function testCreateViewDifferentAttributes()
711711
{
712712
$attr1 = ['class' => 'foobar1'];
713713
$attr2 = ['class' => 'foobar2'];
714-
$list = $this->getMockBuilder('Symfony\Component\Form\ChoiceList\ChoiceListInterface')->getMock();
714+
$list = $this->getMockBuilder(ChoiceListInterface::class)->getMock();
715715
$view1 = new ChoiceListView();
716716
$view2 = new ChoiceListView();
717717

@@ -730,7 +730,7 @@ public function testCreateViewDifferentAttributes()
730730
public function testCreateViewSameAttributesClosure()
731731
{
732732
$attr = function () {};
733-
$list = $this->getMockBuilder('Symfony\Component\Form\ChoiceList\ChoiceListInterface')->getMock();
733+
$list = $this->getMockBuilder(ChoiceListInterface::class)->getMock();
734734
$view = new ChoiceListView();
735735
$view2 = new ChoiceListView();
736736

@@ -763,7 +763,7 @@ public function testCreateViewDifferentAttributesClosure()
763763
{
764764
$attr1 = function () {};
765765
$attr2 = function () {};
766-
$list = $this->getMockBuilder('Symfony\Component\Form\ChoiceList\ChoiceListInterface')->getMock();
766+
$list = $this->getMockBuilder(ChoiceListInterface::class)->getMock();
767767
$view1 = new ChoiceListView();
768768
$view2 = new ChoiceListView();
769769

Tests/ChoiceList/Factory/DefaultChoiceListFactoryTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,7 @@ public function testCreateFromLoaderWithValues()
266266

267267
public function testCreateFromLoaderWithFilter()
268268
{
269-
$loader = $this->getMockBuilder('Symfony\Component\Form\ChoiceList\Loader\ChoiceLoaderInterface')->getMock();
269+
$loader = $this->getMockBuilder(\Symfony\Component\Form\ChoiceList\Loader\ChoiceLoaderInterface::class)->getMock();
270270
$filter = function () {};
271271

272272
$list = $this->factory->createListFromLoader($loader, null, $filter);

Tests/ChoiceList/Factory/PropertyAccessDecoratorTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ public function testCreateFromLoaderPropertyPath()
124124

125125
public function testCreateFromLoaderFilterPropertyPath()
126126
{
127-
$loader = $this->getMockBuilder('Symfony\Component\Form\ChoiceList\Loader\ChoiceLoaderInterface')->getMock();
127+
$loader = $this->getMockBuilder(\Symfony\Component\Form\ChoiceList\Loader\ChoiceLoaderInterface::class)->getMock();
128128
$filteredChoices = [
129129
'two' => (object) ['property' => 'value 2', 'filter' => true],
130130
];

Tests/CompoundFormTest.php

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,7 @@ public function testAddUsingNameButNoTypeAndOptions()
273273

274274
public function testAddThrowsExceptionIfAlreadySubmitted()
275275
{
276-
$this->expectException('Symfony\Component\Form\Exception\AlreadySubmittedException');
276+
$this->expectException(\Symfony\Component\Form\Exception\AlreadySubmittedException::class);
277277
$this->form->submit([]);
278278
$this->form->add($this->getBuilder('foo')->getForm());
279279
}
@@ -290,7 +290,7 @@ public function testRemove()
290290

291291
public function testRemoveThrowsExceptionIfAlreadySubmitted()
292292
{
293-
$this->expectException('Symfony\Component\Form\Exception\AlreadySubmittedException');
293+
$this->expectException(\Symfony\Component\Form\Exception\AlreadySubmittedException::class);
294294
$this->form->add($this->getBuilder('foo')->setCompound(false)->getForm());
295295
$this->form->submit(['foo' => 'bar']);
296296
$this->form->remove('foo');
@@ -351,7 +351,7 @@ public function testAddMapsViewDataToFormIfInitialized()
351351
->method('mapDataToForms')
352352
->with('bar', $this->isInstanceOf(\RecursiveIteratorIterator::class))
353353
->willReturnCallback(function ($data, \RecursiveIteratorIterator $iterator) use ($child) {
354-
$this->assertInstanceOf('Symfony\Component\Form\Util\InheritDataAwareIterator', $iterator->getInnerIterator());
354+
$this->assertInstanceOf(InheritDataAwareIterator::class, $iterator->getInnerIterator());
355355
$this->assertSame([$child->getName() => $child], iterator_to_array($iterator));
356356
});
357357

@@ -441,7 +441,7 @@ public function testSetDataMapsViewDataToChildren()
441441
->method('mapDataToForms')
442442
->with('bar', $this->isInstanceOf(\RecursiveIteratorIterator::class))
443443
->willReturnCallback(function ($data, \RecursiveIteratorIterator $iterator) use ($child1, $child2) {
444-
$this->assertInstanceOf('Symfony\Component\Form\Util\InheritDataAwareIterator', $iterator->getInnerIterator());
444+
$this->assertInstanceOf(InheritDataAwareIterator::class, $iterator->getInnerIterator());
445445
$this->assertSame(['firstName' => $child1, 'lastName' => $child2], iterator_to_array($iterator));
446446
});
447447

@@ -888,7 +888,7 @@ public function testGetErrorsDeepRecursive()
888888

889889
$this->assertSame($error1, $errorsAsArray[0]);
890890
$this->assertSame($error2, $errorsAsArray[1]);
891-
$this->assertInstanceOf('Symfony\Component\Form\FormErrorIterator', $errorsAsArray[2]);
891+
$this->assertInstanceOf(\Symfony\Component\Form\FormErrorIterator::class, $errorsAsArray[2]);
892892

893893
$nestedErrorsAsArray = iterator_to_array($errorsAsArray[2]);
894894

@@ -941,9 +941,9 @@ public function testClearErrorsDeep()
941941
// Basic cases are covered in SimpleFormTest
942942
public function testCreateViewWithChildren()
943943
{
944-
$type = $this->getMockBuilder('Symfony\Component\Form\ResolvedFormTypeInterface')->getMock();
945-
$type1 = $this->getMockBuilder('Symfony\Component\Form\ResolvedFormTypeInterface')->getMock();
946-
$type2 = $this->getMockBuilder('Symfony\Component\Form\ResolvedFormTypeInterface')->getMock();
944+
$type = $this->getMockBuilder(\Symfony\Component\Form\ResolvedFormTypeInterface::class)->getMock();
945+
$type1 = $this->getMockBuilder(\Symfony\Component\Form\ResolvedFormTypeInterface::class)->getMock();
946+
$type2 = $this->getMockBuilder(\Symfony\Component\Form\ResolvedFormTypeInterface::class)->getMock();
947947
$options = ['a' => 'Foo', 'b' => 'Bar'];
948948
$field1 = $this->getBuilder('foo')
949949
->setType($type1)
@@ -997,7 +997,7 @@ public function testNoClickedButtonBeforeSubmission()
997997

998998
public function testNoClickedButton()
999999
{
1000-
$button = $this->getMockBuilder('Symfony\Component\Form\SubmitButton')
1000+
$button = $this->getMockBuilder(\Symfony\Component\Form\SubmitButton::class)
10011001
->setConstructorArgs([new SubmitButtonBuilder('submit')])
10021002
->setMethods(['isClicked'])
10031003
->getMock();
@@ -1019,7 +1019,7 @@ public function testNoClickedButton()
10191019

10201020
public function testClickedButton()
10211021
{
1022-
$button = $this->getMockBuilder('Symfony\Component\Form\SubmitButton')
1022+
$button = $this->getMockBuilder(\Symfony\Component\Form\SubmitButton::class)
10231023
->setConstructorArgs([new SubmitButtonBuilder('submit')])
10241024
->setMethods(['isClicked'])
10251025
->getMock();
@@ -1038,7 +1038,7 @@ public function testClickedButtonFromNestedForm()
10381038
{
10391039
$button = $this->getBuilder('submit')->getForm();
10401040

1041-
$nestedForm = $this->getMockBuilder('Symfony\Component\Form\Form')
1041+
$nestedForm = $this->getMockBuilder(\Symfony\Component\Form\Form::class)
10421042
->setConstructorArgs([$this->getBuilder('nested')])
10431043
->setMethods(['getClickedButton'])
10441044
->getMock();
@@ -1057,7 +1057,7 @@ public function testClickedButtonFromParentForm()
10571057
{
10581058
$button = $this->getBuilder('submit')->getForm();
10591059

1060-
$parentForm = $this->getMockBuilder('Symfony\Component\Form\Form')
1060+
$parentForm = $this->getMockBuilder(\Symfony\Component\Form\Form::class)
10611061
->setConstructorArgs([$this->getBuilder('parent')])
10621062
->setMethods(['getClickedButton'])
10631063
->getMock();

Tests/DependencyInjection/FormPassTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@ public function addTaggedTypeExtensionsDataProvider()
222222

223223
public function testAddTaggedFormTypeExtensionWithoutExtendingAnyType()
224224
{
225-
$this->expectException('InvalidArgumentException');
225+
$this->expectException(\InvalidArgumentException::class);
226226
$this->expectExceptionMessage('The getExtendedTypes() method for service "my.type_extension" does not return any extended types.');
227227
$container = $this->createContainerBuilder();
228228

0 commit comments

Comments
 (0)