Skip to content

Commit d2ea292

Browse files
committed
Merge branch '4.4' into 5.1
* 4.4: Use ::class keyword when possible
2 parents 23d63ae + 351010a commit d2ea292

File tree

63 files changed

+259
-259
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

63 files changed

+259
-259
lines changed

Extension/Core/Type/DateType.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ public function buildForm(FormBuilderInterface $builder, array $options)
124124
$dateFormat,
125125
$timeFormat,
126126
// see https://bugs.php.net/66323
127-
class_exists('IntlTimeZone', false) ? \IntlTimeZone::createDefault() : null,
127+
class_exists(\IntlTimeZone::class, false) ? \IntlTimeZone::createDefault() : null,
128128
$calendar,
129129
$pattern
130130
);

Extension/Core/Type/FileType.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ public function finishView(FormView $view, FormInterface $form, array $options)
114114
public function configureOptions(OptionsResolver $resolver)
115115
{
116116
$dataClass = null;
117-
if (class_exists('Symfony\Component\HttpFoundation\File\File')) {
117+
if (class_exists(\Symfony\Component\HttpFoundation\File\File::class)) {
118118
$dataClass = function (Options $options) {
119119
return $options['multiple'] ? null : 'Symfony\Component\HttpFoundation\File\File';
120120
};

Tests/AbstractExtensionTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ public function testHasType()
2828
public function testGetType()
2929
{
3030
$loader = new ConcreteExtension();
31-
$this->assertInstanceOf('Symfony\Component\Form\Tests\Fixtures\FooType', $loader->getType('Symfony\Component\Form\Tests\Fixtures\FooType'));
31+
$this->assertInstanceOf(FooType::class, $loader->getType('Symfony\Component\Form\Tests\Fixtures\FooType'));
3232
}
3333
}
3434

Tests/AbstractFormTest.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ abstract class AbstractFormTest extends TestCase
3838
protected function setUp(): void
3939
{
4040
$this->dispatcher = new EventDispatcher();
41-
$this->factory = $this->getMockBuilder('Symfony\Component\Form\FormFactoryInterface')->getMock();
41+
$this->factory = $this->getMockBuilder(\Symfony\Component\Form\FormFactoryInterface::class)->getMock();
4242
$this->form = $this->createForm();
4343
}
4444

@@ -58,16 +58,16 @@ protected function getBuilder(?string $name = 'name', EventDispatcherInterface $
5858

5959
protected function getDataMapper(): MockObject
6060
{
61-
return $this->getMockBuilder('Symfony\Component\Form\DataMapperInterface')->getMock();
61+
return $this->getMockBuilder(\Symfony\Component\Form\DataMapperInterface::class)->getMock();
6262
}
6363

6464
protected function getDataTransformer(): MockObject
6565
{
66-
return $this->getMockBuilder('Symfony\Component\Form\DataTransformerInterface')->getMock();
66+
return $this->getMockBuilder(\Symfony\Component\Form\DataTransformerInterface::class)->getMock();
6767
}
6868

6969
protected function getFormValidator(): MockObject
7070
{
71-
return $this->getMockBuilder('Symfony\Component\Form\FormValidatorInterface')->getMock();
71+
return $this->getMockBuilder(\Symfony\Component\Form\FormValidatorInterface::class)->getMock();
7272
}
7373
}

Tests/AbstractLayoutTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ protected function setUp(): void
3434

3535
\Locale::setDefault('en');
3636

37-
$this->csrfTokenManager = $this->getMockBuilder('Symfony\Component\Security\Csrf\CsrfTokenManagerInterface')->getMock();
37+
$this->csrfTokenManager = $this->getMockBuilder(\Symfony\Component\Security\Csrf\CsrfTokenManagerInterface::class)->getMock();
3838

3939
parent::setUp();
4040
}

Tests/AbstractRequestHandlerTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ abstract class AbstractRequestHandlerTest extends TestCase
4242

4343
protected function setUp(): void
4444
{
45-
$this->serverParams = $this->getMockBuilder('Symfony\Component\Form\Util\ServerParams')->setMethods(['getNormalizedIniPostMaxSize', 'getContentLength'])->getMock();
45+
$this->serverParams = $this->getMockBuilder(\Symfony\Component\Form\Util\ServerParams::class)->setMethods(['getNormalizedIniPostMaxSize', 'getContentLength'])->getMock();
4646
$this->requestHandler = $this->getRequestHandler();
4747
$this->factory = Forms::createFormFactoryBuilder()->getFormFactory();
4848
$this->request = null;
@@ -405,7 +405,7 @@ protected function createForm($name, $method = null, $compound = false)
405405

406406
protected function createBuilder($name, $compound = false, array $options = [])
407407
{
408-
$builder = new FormBuilder($name, null, new EventDispatcher(), $this->getMockBuilder('Symfony\Component\Form\FormFactoryInterface')->getMock(), $options);
408+
$builder = new FormBuilder($name, null, new EventDispatcher(), $this->getMockBuilder(\Symfony\Component\Form\FormFactoryInterface::class)->getMock(), $options);
409409
$builder->setCompound($compound);
410410

411411
if ($compound) {

Tests/ButtonTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,13 @@ class ButtonTest extends TestCase
2626

2727
protected function setUp(): void
2828
{
29-
$this->dispatcher = $this->getMockBuilder('Symfony\Component\EventDispatcher\EventDispatcherInterface')->getMock();
30-
$this->factory = $this->getMockBuilder('Symfony\Component\Form\FormFactoryInterface')->getMock();
29+
$this->dispatcher = $this->getMockBuilder(\Symfony\Component\EventDispatcher\EventDispatcherInterface::class)->getMock();
30+
$this->factory = $this->getMockBuilder(\Symfony\Component\Form\FormFactoryInterface::class)->getMock();
3131
}
3232

3333
public function testSetParentOnSubmittedButton()
3434
{
35-
$this->expectException('Symfony\Component\Form\Exception\AlreadySubmittedException');
35+
$this->expectException(\Symfony\Component\Form\Exception\AlreadySubmittedException::class);
3636
$button = $this->getButtonBuilder('button')
3737
->getForm()
3838
;

Tests/ChoiceList/Factory/DefaultChoiceListFactoryTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,7 @@ function ($choice) {
247247

248248
public function testCreateFromLoader()
249249
{
250-
$loader = $this->getMockBuilder('Symfony\Component\Form\ChoiceList\Loader\ChoiceLoaderInterface')->getMock();
250+
$loader = $this->getMockBuilder(\Symfony\Component\Form\ChoiceList\Loader\ChoiceLoaderInterface::class)->getMock();
251251

252252
$list = $this->factory->createListFromLoader($loader);
253253

@@ -256,7 +256,7 @@ public function testCreateFromLoader()
256256

257257
public function testCreateFromLoaderWithValues()
258258
{
259-
$loader = $this->getMockBuilder('Symfony\Component\Form\ChoiceList\Loader\ChoiceLoaderInterface')->getMock();
259+
$loader = $this->getMockBuilder(\Symfony\Component\Form\ChoiceList\Loader\ChoiceLoaderInterface::class)->getMock();
260260

261261
$value = function () {};
262262
$list = $this->factory->createListFromLoader($loader, $value);

Tests/ChoiceList/Factory/PropertyAccessDecoratorTest.php

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ class PropertyAccessDecoratorTest extends TestCase
3535

3636
protected function setUp(): void
3737
{
38-
$this->decoratedFactory = $this->getMockBuilder('Symfony\Component\Form\ChoiceList\Factory\ChoiceListFactoryInterface')->getMock();
38+
$this->decoratedFactory = $this->getMockBuilder(\Symfony\Component\Form\ChoiceList\Factory\ChoiceListFactoryInterface::class)->getMock();
3939
$this->factory = new PropertyAccessDecorator($this->decoratedFactory);
4040
}
4141

@@ -110,7 +110,7 @@ public function testCreateFromChoicesFilterPropertyPathInstance()
110110

111111
public function testCreateFromLoaderPropertyPath()
112112
{
113-
$loader = $this->getMockBuilder('Symfony\Component\Form\ChoiceList\Loader\ChoiceLoaderInterface')->getMock();
113+
$loader = $this->getMockBuilder(\Symfony\Component\Form\ChoiceList\Loader\ChoiceLoaderInterface::class)->getMock();
114114

115115
$this->decoratedFactory->expects($this->once())
116116
->method('createListFromLoader')
@@ -160,7 +160,7 @@ public function testCreateFromChoicesAssumeNullIfValuePropertyPathUnreadable()
160160
// https://github.com/symfony/symfony/issues/5494
161161
public function testCreateFromChoiceLoaderAssumeNullIfValuePropertyPathUnreadable()
162162
{
163-
$loader = $this->getMockBuilder('Symfony\Component\Form\ChoiceList\Loader\ChoiceLoaderInterface')->getMock();
163+
$loader = $this->getMockBuilder(\Symfony\Component\Form\ChoiceList\Loader\ChoiceLoaderInterface::class)->getMock();
164164

165165
$this->decoratedFactory->expects($this->once())
166166
->method('createListFromLoader')
@@ -174,7 +174,7 @@ public function testCreateFromChoiceLoaderAssumeNullIfValuePropertyPathUnreadabl
174174

175175
public function testCreateFromLoaderPropertyPathInstance()
176176
{
177-
$loader = $this->getMockBuilder('Symfony\Component\Form\ChoiceList\Loader\ChoiceLoaderInterface')->getMock();
177+
$loader = $this->getMockBuilder(\Symfony\Component\Form\ChoiceList\Loader\ChoiceLoaderInterface::class)->getMock();
178178

179179
$this->decoratedFactory->expects($this->once())
180180
->method('createListFromLoader')
@@ -188,7 +188,7 @@ public function testCreateFromLoaderPropertyPathInstance()
188188

189189
public function testCreateViewPreferredChoicesAsPropertyPath()
190190
{
191-
$list = $this->getMockBuilder('Symfony\Component\Form\ChoiceList\ChoiceListInterface')->getMock();
191+
$list = $this->getMockBuilder(\Symfony\Component\Form\ChoiceList\ChoiceListInterface::class)->getMock();
192192

193193
$this->decoratedFactory->expects($this->once())
194194
->method('createView')
@@ -202,7 +202,7 @@ public function testCreateViewPreferredChoicesAsPropertyPath()
202202

203203
public function testCreateViewPreferredChoicesAsPropertyPathInstance()
204204
{
205-
$list = $this->getMockBuilder('Symfony\Component\Form\ChoiceList\ChoiceListInterface')->getMock();
205+
$list = $this->getMockBuilder(\Symfony\Component\Form\ChoiceList\ChoiceListInterface::class)->getMock();
206206

207207
$this->decoratedFactory->expects($this->once())
208208
->method('createView')
@@ -217,7 +217,7 @@ public function testCreateViewPreferredChoicesAsPropertyPathInstance()
217217
// https://github.com/symfony/symfony/issues/5494
218218
public function testCreateViewAssumeNullIfPreferredChoicesPropertyPathUnreadable()
219219
{
220-
$list = $this->getMockBuilder('Symfony\Component\Form\ChoiceList\ChoiceListInterface')->getMock();
220+
$list = $this->getMockBuilder(\Symfony\Component\Form\ChoiceList\ChoiceListInterface::class)->getMock();
221221

222222
$this->decoratedFactory->expects($this->once())
223223
->method('createView')
@@ -231,7 +231,7 @@ public function testCreateViewAssumeNullIfPreferredChoicesPropertyPathUnreadable
231231

232232
public function testCreateViewLabelsAsPropertyPath()
233233
{
234-
$list = $this->getMockBuilder('Symfony\Component\Form\ChoiceList\ChoiceListInterface')->getMock();
234+
$list = $this->getMockBuilder(\Symfony\Component\Form\ChoiceList\ChoiceListInterface::class)->getMock();
235235

236236
$this->decoratedFactory->expects($this->once())
237237
->method('createView')
@@ -245,7 +245,7 @@ public function testCreateViewLabelsAsPropertyPath()
245245

246246
public function testCreateViewLabelsAsPropertyPathInstance()
247247
{
248-
$list = $this->getMockBuilder('Symfony\Component\Form\ChoiceList\ChoiceListInterface')->getMock();
248+
$list = $this->getMockBuilder(\Symfony\Component\Form\ChoiceList\ChoiceListInterface::class)->getMock();
249249

250250
$this->decoratedFactory->expects($this->once())
251251
->method('createView')
@@ -259,7 +259,7 @@ public function testCreateViewLabelsAsPropertyPathInstance()
259259

260260
public function testCreateViewIndicesAsPropertyPath()
261261
{
262-
$list = $this->getMockBuilder('Symfony\Component\Form\ChoiceList\ChoiceListInterface')->getMock();
262+
$list = $this->getMockBuilder(\Symfony\Component\Form\ChoiceList\ChoiceListInterface::class)->getMock();
263263

264264
$this->decoratedFactory->expects($this->once())
265265
->method('createView')
@@ -273,7 +273,7 @@ public function testCreateViewIndicesAsPropertyPath()
273273

274274
public function testCreateViewIndicesAsPropertyPathInstance()
275275
{
276-
$list = $this->getMockBuilder('Symfony\Component\Form\ChoiceList\ChoiceListInterface')->getMock();
276+
$list = $this->getMockBuilder(\Symfony\Component\Form\ChoiceList\ChoiceListInterface::class)->getMock();
277277

278278
$this->decoratedFactory->expects($this->once())
279279
->method('createView')
@@ -287,7 +287,7 @@ public function testCreateViewIndicesAsPropertyPathInstance()
287287

288288
public function testCreateViewGroupsAsPropertyPath()
289289
{
290-
$list = $this->getMockBuilder('Symfony\Component\Form\ChoiceList\ChoiceListInterface')->getMock();
290+
$list = $this->getMockBuilder(\Symfony\Component\Form\ChoiceList\ChoiceListInterface::class)->getMock();
291291

292292
$this->decoratedFactory->expects($this->once())
293293
->method('createView')
@@ -301,7 +301,7 @@ public function testCreateViewGroupsAsPropertyPath()
301301

302302
public function testCreateViewGroupsAsPropertyPathInstance()
303303
{
304-
$list = $this->getMockBuilder('Symfony\Component\Form\ChoiceList\ChoiceListInterface')->getMock();
304+
$list = $this->getMockBuilder(\Symfony\Component\Form\ChoiceList\ChoiceListInterface::class)->getMock();
305305

306306
$this->decoratedFactory->expects($this->once())
307307
->method('createView')
@@ -316,7 +316,7 @@ public function testCreateViewGroupsAsPropertyPathInstance()
316316
// https://github.com/symfony/symfony/issues/5494
317317
public function testCreateViewAssumeNullIfGroupsPropertyPathUnreadable()
318318
{
319-
$list = $this->getMockBuilder('Symfony\Component\Form\ChoiceList\ChoiceListInterface')->getMock();
319+
$list = $this->getMockBuilder(\Symfony\Component\Form\ChoiceList\ChoiceListInterface::class)->getMock();
320320

321321
$this->decoratedFactory->expects($this->once())
322322
->method('createView')
@@ -330,7 +330,7 @@ public function testCreateViewAssumeNullIfGroupsPropertyPathUnreadable()
330330

331331
public function testCreateViewAttrAsPropertyPath()
332332
{
333-
$list = $this->getMockBuilder('Symfony\Component\Form\ChoiceList\ChoiceListInterface')->getMock();
333+
$list = $this->getMockBuilder(\Symfony\Component\Form\ChoiceList\ChoiceListInterface::class)->getMock();
334334

335335
$this->decoratedFactory->expects($this->once())
336336
->method('createView')
@@ -344,7 +344,7 @@ public function testCreateViewAttrAsPropertyPath()
344344

345345
public function testCreateViewAttrAsPropertyPathInstance()
346346
{
347-
$list = $this->getMockBuilder('Symfony\Component\Form\ChoiceList\ChoiceListInterface')->getMock();
347+
$list = $this->getMockBuilder(\Symfony\Component\Form\ChoiceList\ChoiceListInterface::class)->getMock();
348348

349349
$this->decoratedFactory->expects($this->once())
350350
->method('createView')

Tests/ChoiceList/LazyChoiceListTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,8 @@ class LazyChoiceListTest extends TestCase
3939

4040
protected function setUp(): void
4141
{
42-
$this->loadedList = $this->getMockBuilder('Symfony\Component\Form\ChoiceList\ChoiceListInterface')->getMock();
43-
$this->loader = $this->getMockBuilder('Symfony\Component\Form\ChoiceList\Loader\ChoiceLoaderInterface')->getMock();
42+
$this->loadedList = $this->getMockBuilder(\Symfony\Component\Form\ChoiceList\ChoiceListInterface::class)->getMock();
43+
$this->loader = $this->getMockBuilder(\Symfony\Component\Form\ChoiceList\Loader\ChoiceLoaderInterface::class)->getMock();
4444
$this->value = function () {};
4545
$this->list = new LazyChoiceList($this->loader, $this->value);
4646
}

Tests/Command/DebugCommandTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ public function testDebugFormTypeOption()
8686

8787
public function testDebugSingleFormTypeNotFound()
8888
{
89-
$this->expectException('Symfony\Component\Console\Exception\InvalidArgumentException');
89+
$this->expectException(InvalidArgumentException::class);
9090
$this->expectExceptionMessage('Could not find type "NonExistentType"');
9191
$tester = $this->createCommandTester();
9292
$tester->execute(['class' => 'NonExistentType'], ['decorated' => false, 'interactive' => false]);
@@ -141,7 +141,7 @@ public function testDebugAmbiguousFormTypeInteractive()
141141

142142
public function testDebugInvalidFormType()
143143
{
144-
$this->expectException('InvalidArgumentException');
144+
$this->expectException(\InvalidArgumentException::class);
145145
$this->createCommandTester()->execute(['class' => 'test']);
146146
}
147147

Tests/Extension/Core/DataTransformer/ArrayToPartsTransformerTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ public function testTransformEmpty()
7070

7171
public function testTransformRequiresArray()
7272
{
73-
$this->expectException('Symfony\Component\Form\Exception\TransformationFailedException');
73+
$this->expectException(\Symfony\Component\Form\Exception\TransformationFailedException::class);
7474
$this->transformer->transform('12345');
7575
}
7676

@@ -123,7 +123,7 @@ public function testReverseTransformCompletelyNull()
123123

124124
public function testReverseTransformPartiallyNull()
125125
{
126-
$this->expectException('Symfony\Component\Form\Exception\TransformationFailedException');
126+
$this->expectException(\Symfony\Component\Form\Exception\TransformationFailedException::class);
127127
$input = [
128128
'first' => [
129129
'a' => '1',
@@ -138,7 +138,7 @@ public function testReverseTransformPartiallyNull()
138138

139139
public function testReverseTransformRequiresArray()
140140
{
141-
$this->expectException('Symfony\Component\Form\Exception\TransformationFailedException');
141+
$this->expectException(\Symfony\Component\Form\Exception\TransformationFailedException::class);
142142
$this->transformer->reverseTransform('12345');
143143
}
144144
}

Tests/Extension/Core/DataTransformer/BaseDateTimeTransformerTest.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,15 @@ class BaseDateTimeTransformerTest extends TestCase
1717
{
1818
public function testConstructFailsIfInputTimezoneIsInvalid()
1919
{
20-
$this->expectException('Symfony\Component\Form\Exception\InvalidArgumentException');
20+
$this->expectException(\Symfony\Component\Form\Exception\InvalidArgumentException::class);
2121
$this->expectExceptionMessage('this_timezone_does_not_exist');
22-
$this->getMockBuilder('Symfony\Component\Form\Extension\Core\DataTransformer\BaseDateTimeTransformer')->setConstructorArgs(['this_timezone_does_not_exist'])->getMock();
22+
$this->getMockBuilder(\Symfony\Component\Form\Extension\Core\DataTransformer\BaseDateTimeTransformer::class)->setConstructorArgs(['this_timezone_does_not_exist'])->getMock();
2323
}
2424

2525
public function testConstructFailsIfOutputTimezoneIsInvalid()
2626
{
27-
$this->expectException('Symfony\Component\Form\Exception\InvalidArgumentException');
27+
$this->expectException(\Symfony\Component\Form\Exception\InvalidArgumentException::class);
2828
$this->expectExceptionMessage('that_timezone_does_not_exist');
29-
$this->getMockBuilder('Symfony\Component\Form\Extension\Core\DataTransformer\BaseDateTimeTransformer')->setConstructorArgs([null, 'that_timezone_does_not_exist'])->getMock();
29+
$this->getMockBuilder(\Symfony\Component\Form\Extension\Core\DataTransformer\BaseDateTimeTransformer::class)->setConstructorArgs([null, 'that_timezone_does_not_exist'])->getMock();
3030
}
3131
}

Tests/Extension/Core/DataTransformer/BooleanToStringTransformerTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,13 +47,13 @@ public function testTransformAcceptsNull()
4747

4848
public function testTransformFailsIfString()
4949
{
50-
$this->expectException('Symfony\Component\Form\Exception\TransformationFailedException');
50+
$this->expectException(\Symfony\Component\Form\Exception\TransformationFailedException::class);
5151
$this->transformer->transform('1');
5252
}
5353

5454
public function testReverseTransformFailsIfInteger()
5555
{
56-
$this->expectException('Symfony\Component\Form\Exception\TransformationFailedException');
56+
$this->expectException(\Symfony\Component\Form\Exception\TransformationFailedException::class);
5757
$this->transformer->reverseTransform(1);
5858
}
5959

@@ -75,7 +75,7 @@ public function testCustomFalseValues()
7575

7676
public function testTrueValueContainedInFalseValues()
7777
{
78-
$this->expectException('Symfony\Component\Form\Exception\InvalidArgumentException');
78+
$this->expectException(\Symfony\Component\Form\Exception\InvalidArgumentException::class);
7979
new BooleanToStringTransformer('0', [null, '0']);
8080
}
8181

Tests/Extension/Core/DataTransformer/ChoiceToValueTransformerTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ public function reverseTransformExpectsStringOrNullProvider()
9191
*/
9292
public function testReverseTransformExpectsStringOrNull($value)
9393
{
94-
$this->expectException('Symfony\Component\Form\Exception\TransformationFailedException');
94+
$this->expectException(\Symfony\Component\Form\Exception\TransformationFailedException::class);
9595
$this->transformer->reverseTransform($value);
9696
}
9797
}

0 commit comments

Comments
 (0)