Skip to content

Commit 9b4d36b

Browse files
fre5hnicolas-grekas
authored andcommitted
Use ::class constants instead of __NAMESPACE__ when possible
1 parent 13dbd70 commit 9b4d36b

24 files changed

+30
-30
lines changed

Extension/Core/Type/BirthdayType.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ public function configureOptions(OptionsResolver $resolver)
3131
*/
3232
public function getParent()
3333
{
34-
return __NAMESPACE__.'\DateType';
34+
return DateType::class;
3535
}
3636

3737
/**

Extension/Core/Type/ChoiceType.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -391,12 +391,12 @@ private function addSubForm(FormBuilderInterface $builder, $name, ChoiceView $ch
391391
];
392392

393393
if ($options['multiple']) {
394-
$choiceType = __NAMESPACE__.'\CheckboxType';
394+
$choiceType = CheckboxType::class;
395395
// The user can check 0 or more checkboxes. If required
396396
// is true, they are required to check all of them.
397397
$choiceOpts['required'] = false;
398398
} else {
399-
$choiceType = __NAMESPACE__.'\RadioType';
399+
$choiceType = RadioType::class;
400400
}
401401

402402
$builder->add($name, $choiceType, $choiceOpts);

Extension/Core/Type/CollectionType.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ public function configureOptions(OptionsResolver $resolver)
9494
'prototype' => true,
9595
'prototype_data' => null,
9696
'prototype_name' => '__name__',
97-
'entry_type' => __NAMESPACE__.'\TextType',
97+
'entry_type' => TextType::class,
9898
'entry_options' => [],
9999
'delete_empty' => false,
100100
]);

Extension/Core/Type/CountryType.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ public function configureOptions(OptionsResolver $resolver)
5555
*/
5656
public function getParent()
5757
{
58-
return __NAMESPACE__.'\ChoiceType';
58+
return ChoiceType::class;
5959
}
6060

6161
/**

Extension/Core/Type/CurrencyType.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ public function configureOptions(OptionsResolver $resolver)
5555
*/
5656
public function getParent()
5757
{
58-
return __NAMESPACE__.'\ChoiceType';
58+
return ChoiceType::class;
5959
}
6060

6161
/**

Extension/Core/Type/DateTimeType.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -158,8 +158,8 @@ public function buildForm(FormBuilderInterface $builder, array $options)
158158
'time' => $timeParts,
159159
]),
160160
]))
161-
->add('date', __NAMESPACE__.'\DateType', $dateOptions)
162-
->add('time', __NAMESPACE__.'\TimeType', $timeOptions)
161+
->add('date', DateType::class, $dateOptions)
162+
->add('time', TimeType::class, $timeOptions)
163163
;
164164
}
165165

Extension/Core/Type/EmailType.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ class EmailType extends AbstractType
2020
*/
2121
public function getParent()
2222
{
23-
return __NAMESPACE__.'\TextType';
23+
return TextType::class;
2424
}
2525

2626
/**

Extension/Core/Type/LanguageType.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ public function configureOptions(OptionsResolver $resolver)
5555
*/
5656
public function getParent()
5757
{
58-
return __NAMESPACE__.'\ChoiceType';
58+
return ChoiceType::class;
5959
}
6060

6161
/**

Extension/Core/Type/LocaleType.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ public function configureOptions(OptionsResolver $resolver)
5555
*/
5656
public function getParent()
5757
{
58-
return __NAMESPACE__.'\ChoiceType';
58+
return ChoiceType::class;
5959
}
6060

6161
/**

Extension/Core/Type/PasswordType.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ public function configureOptions(OptionsResolver $resolver)
4444
*/
4545
public function getParent()
4646
{
47-
return __NAMESPACE__.'\TextType';
47+
return TextType::class;
4848
}
4949

5050
/**

Extension/Core/Type/RadioType.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ class RadioType extends AbstractType
2020
*/
2121
public function getParent()
2222
{
23-
return __NAMESPACE__.'\CheckboxType';
23+
return CheckboxType::class;
2424
}
2525

2626
/**

Extension/Core/Type/RangeType.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ class RangeType extends AbstractType
2020
*/
2121
public function getParent()
2222
{
23-
return __NAMESPACE__.'\TextType';
23+
return TextType::class;
2424
}
2525

2626
/**

Extension/Core/Type/RepeatedType.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ public function buildForm(FormBuilderInterface $builder, array $options)
4747
public function configureOptions(OptionsResolver $resolver)
4848
{
4949
$resolver->setDefaults([
50-
'type' => __NAMESPACE__.'\TextType',
50+
'type' => TextType::class,
5151
'options' => [],
5252
'first_options' => [],
5353
'second_options' => [],

Extension/Core/Type/ResetType.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ class ResetType extends AbstractType implements ButtonTypeInterface
2626
*/
2727
public function getParent()
2828
{
29-
return __NAMESPACE__.'\ButtonType';
29+
return ButtonType::class;
3030
}
3131

3232
/**

Extension/Core/Type/SearchType.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ class SearchType extends AbstractType
2020
*/
2121
public function getParent()
2222
{
23-
return __NAMESPACE__.'\TextType';
23+
return TextType::class;
2424
}
2525

2626
/**

Extension/Core/Type/SubmitType.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ public function buildView(FormView $view, FormInterface $form, array $options)
3333
*/
3434
public function getParent()
3535
{
36-
return __NAMESPACE__.'\ButtonType';
36+
return ButtonType::class;
3737
}
3838

3939
/**

Extension/Core/Type/TextareaType.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ public function buildView(FormView $view, FormInterface $form, array $options)
3030
*/
3131
public function getParent()
3232
{
33-
return __NAMESPACE__.'\TextType';
33+
return TextType::class;
3434
}
3535

3636
/**

Extension/Core/Type/TimezoneType.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ public function configureOptions(OptionsResolver $resolver)
7777
*/
7878
public function getParent()
7979
{
80-
return __NAMESPACE__.'\ChoiceType';
80+
return ChoiceType::class;
8181
}
8282

8383
/**

Extension/Core/Type/UrlType.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ public function configureOptions(OptionsResolver $resolver)
5656
*/
5757
public function getParent()
5858
{
59-
return __NAMESPACE__.'\TextType';
59+
return TextType::class;
6060
}
6161

6262
/**

Extension/Validator/Constraints/FormValidator.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ class FormValidator extends ConstraintValidator
3030
public function validate($form, Constraint $formConstraint)
3131
{
3232
if (!$formConstraint instanceof Form) {
33-
throw new UnexpectedTypeException($formConstraint, __NAMESPACE__.'\Form');
33+
throw new UnexpectedTypeException($formConstraint, Form::class);
3434
}
3535

3636
if (!$form instanceof FormInterface) {

Tests/Fixtures/FooSubType.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,6 @@ class FooSubType extends AbstractType
1717
{
1818
public function getParent()
1919
{
20-
return __NAMESPACE__.'\FooType';
20+
return FooType::class;
2121
}
2222
}

Tests/Fixtures/FooTypeBarExtension.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,6 @@ public function getAllowedOptionValues()
3030

3131
public function getExtendedType()
3232
{
33-
return __NAMESPACE__.'\FooType';
33+
return FooType::class;
3434
}
3535
}

Tests/Fixtures/FooTypeBazExtension.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,6 @@ public function buildForm(FormBuilderInterface $builder, array $options)
2323

2424
public function getExtendedType()
2525
{
26-
return __NAMESPACE__.'\FooType';
26+
return FooType::class;
2727
}
2828
}

Tests/ResolvedFormTypeTest.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -350,12 +350,12 @@ public function testBlockPrefixDefaultsToFQCNIfNoName($typeClass, $blockPrefix)
350350
public function provideTypeClassBlockPrefixTuples()
351351
{
352352
return [
353-
[__NAMESPACE__.'\Fixtures\FooType', 'foo'],
354-
[__NAMESPACE__.'\Fixtures\Foo', 'foo'],
355-
[__NAMESPACE__.'\Fixtures\Type', 'type'],
356-
[__NAMESPACE__.'\Fixtures\FooBarHTMLType', 'foo_bar_html'],
353+
[Fixtures\FooType::class, 'foo'],
354+
[Fixtures\Foo::class, 'foo'],
355+
[Fixtures\Type::class, 'type'],
356+
[Fixtures\FooBarHTMLType::class, 'foo_bar_html'],
357357
[__NAMESPACE__.'\Fixtures\Foo1Bar2Type', 'foo1_bar2'],
358-
[__NAMESPACE__.'\Fixtures\FBooType', 'f_boo'],
358+
[Fixtures\FBooType::class, 'f_boo'],
359359
];
360360
}
361361

0 commit comments

Comments
 (0)