diff --git a/Extension/Core/Type/BirthdayType.php b/Extension/Core/Type/BirthdayType.php index acb8d02b8c..a4e8b8d41c 100644 --- a/Extension/Core/Type/BirthdayType.php +++ b/Extension/Core/Type/BirthdayType.php @@ -31,7 +31,7 @@ public function configureOptions(OptionsResolver $resolver) */ public function getParent() { - return __NAMESPACE__.'\DateType'; + return DateType::class; } /** diff --git a/Extension/Core/Type/ChoiceType.php b/Extension/Core/Type/ChoiceType.php index 9866ab2456..4be8814977 100644 --- a/Extension/Core/Type/ChoiceType.php +++ b/Extension/Core/Type/ChoiceType.php @@ -373,12 +373,12 @@ private function addSubForm(FormBuilderInterface $builder, string $name, ChoiceV ]; if ($options['multiple']) { - $choiceType = __NAMESPACE__.'\CheckboxType'; + $choiceType = CheckboxType::class; // The user can check 0 or more checkboxes. If required // is true, they are required to check all of them. $choiceOpts['required'] = false; } else { - $choiceType = __NAMESPACE__.'\RadioType'; + $choiceType = RadioType::class; } $builder->add($name, $choiceType, $choiceOpts); diff --git a/Extension/Core/Type/CollectionType.php b/Extension/Core/Type/CollectionType.php index fc36cca6da..b441f08ce6 100644 --- a/Extension/Core/Type/CollectionType.php +++ b/Extension/Core/Type/CollectionType.php @@ -94,7 +94,7 @@ public function configureOptions(OptionsResolver $resolver) 'prototype' => true, 'prototype_data' => null, 'prototype_name' => '__name__', - 'entry_type' => __NAMESPACE__.'\TextType', + 'entry_type' => TextType::class, 'entry_options' => [], 'delete_empty' => false, ]); diff --git a/Extension/Core/Type/CountryType.php b/Extension/Core/Type/CountryType.php index 1899420c6d..00a19c44f2 100644 --- a/Extension/Core/Type/CountryType.php +++ b/Extension/Core/Type/CountryType.php @@ -47,7 +47,7 @@ public function configureOptions(OptionsResolver $resolver) */ public function getParent() { - return __NAMESPACE__.'\ChoiceType'; + return ChoiceType::class; } /** diff --git a/Extension/Core/Type/CurrencyType.php b/Extension/Core/Type/CurrencyType.php index 671991452c..58136ddb86 100644 --- a/Extension/Core/Type/CurrencyType.php +++ b/Extension/Core/Type/CurrencyType.php @@ -44,7 +44,7 @@ public function configureOptions(OptionsResolver $resolver) */ public function getParent() { - return __NAMESPACE__.'\ChoiceType'; + return ChoiceType::class; } /** diff --git a/Extension/Core/Type/DateTimeType.php b/Extension/Core/Type/DateTimeType.php index 889eb9d029..fd9d8cd97f 100644 --- a/Extension/Core/Type/DateTimeType.php +++ b/Extension/Core/Type/DateTimeType.php @@ -168,8 +168,8 @@ public function buildForm(FormBuilderInterface $builder, array $options) 'time' => $timeParts, ]), ])) - ->add('date', __NAMESPACE__.'\DateType', $dateOptions) - ->add('time', __NAMESPACE__.'\TimeType', $timeOptions) + ->add('date', DateType::class, $dateOptions) + ->add('time', TimeType::class, $timeOptions) ; } diff --git a/Extension/Core/Type/EmailType.php b/Extension/Core/Type/EmailType.php index 2434778c76..1bc1019ab9 100644 --- a/Extension/Core/Type/EmailType.php +++ b/Extension/Core/Type/EmailType.php @@ -20,7 +20,7 @@ class EmailType extends AbstractType */ public function getParent() { - return __NAMESPACE__.'\TextType'; + return TextType::class; } /** diff --git a/Extension/Core/Type/LanguageType.php b/Extension/Core/Type/LanguageType.php index 47cd043a1b..82fe37a2fc 100644 --- a/Extension/Core/Type/LanguageType.php +++ b/Extension/Core/Type/LanguageType.php @@ -47,7 +47,7 @@ public function configureOptions(OptionsResolver $resolver) */ public function getParent() { - return __NAMESPACE__.'\ChoiceType'; + return ChoiceType::class; } /** diff --git a/Extension/Core/Type/LocaleType.php b/Extension/Core/Type/LocaleType.php index b0a60161a4..bc6234fd05 100644 --- a/Extension/Core/Type/LocaleType.php +++ b/Extension/Core/Type/LocaleType.php @@ -44,7 +44,7 @@ public function configureOptions(OptionsResolver $resolver) */ public function getParent() { - return __NAMESPACE__.'\ChoiceType'; + return ChoiceType::class; } /** diff --git a/Extension/Core/Type/PasswordType.php b/Extension/Core/Type/PasswordType.php index 5a5b2605a4..a11708084f 100644 --- a/Extension/Core/Type/PasswordType.php +++ b/Extension/Core/Type/PasswordType.php @@ -44,7 +44,7 @@ public function configureOptions(OptionsResolver $resolver) */ public function getParent() { - return __NAMESPACE__.'\TextType'; + return TextType::class; } /** diff --git a/Extension/Core/Type/RadioType.php b/Extension/Core/Type/RadioType.php index 7c0e860847..471075b9a6 100644 --- a/Extension/Core/Type/RadioType.php +++ b/Extension/Core/Type/RadioType.php @@ -20,7 +20,7 @@ class RadioType extends AbstractType */ public function getParent() { - return __NAMESPACE__.'\CheckboxType'; + return CheckboxType::class; } /** diff --git a/Extension/Core/Type/RangeType.php b/Extension/Core/Type/RangeType.php index a69633c540..36ecdb96da 100644 --- a/Extension/Core/Type/RangeType.php +++ b/Extension/Core/Type/RangeType.php @@ -20,7 +20,7 @@ class RangeType extends AbstractType */ public function getParent() { - return __NAMESPACE__.'\TextType'; + return TextType::class; } /** diff --git a/Extension/Core/Type/RepeatedType.php b/Extension/Core/Type/RepeatedType.php index 5f9ee5329c..ffb7520a58 100644 --- a/Extension/Core/Type/RepeatedType.php +++ b/Extension/Core/Type/RepeatedType.php @@ -47,7 +47,7 @@ public function buildForm(FormBuilderInterface $builder, array $options) public function configureOptions(OptionsResolver $resolver) { $resolver->setDefaults([ - 'type' => __NAMESPACE__.'\TextType', + 'type' => TextType::class, 'options' => [], 'first_options' => [], 'second_options' => [], diff --git a/Extension/Core/Type/ResetType.php b/Extension/Core/Type/ResetType.php index 16978ec5f1..ce8013d1b0 100644 --- a/Extension/Core/Type/ResetType.php +++ b/Extension/Core/Type/ResetType.php @@ -26,7 +26,7 @@ class ResetType extends AbstractType implements ButtonTypeInterface */ public function getParent() { - return __NAMESPACE__.'\ButtonType'; + return ButtonType::class; } /** diff --git a/Extension/Core/Type/SearchType.php b/Extension/Core/Type/SearchType.php index 4766ad094c..c817a26d02 100644 --- a/Extension/Core/Type/SearchType.php +++ b/Extension/Core/Type/SearchType.php @@ -20,7 +20,7 @@ class SearchType extends AbstractType */ public function getParent() { - return __NAMESPACE__.'\TextType'; + return TextType::class; } /** diff --git a/Extension/Core/Type/SubmitType.php b/Extension/Core/Type/SubmitType.php index bf3cea2414..945156efc6 100644 --- a/Extension/Core/Type/SubmitType.php +++ b/Extension/Core/Type/SubmitType.php @@ -47,7 +47,7 @@ public function configureOptions(OptionsResolver $resolver) */ public function getParent() { - return __NAMESPACE__.'\ButtonType'; + return ButtonType::class; } /** diff --git a/Extension/Core/Type/TextareaType.php b/Extension/Core/Type/TextareaType.php index e4127f932c..7db19d8aed 100644 --- a/Extension/Core/Type/TextareaType.php +++ b/Extension/Core/Type/TextareaType.php @@ -30,7 +30,7 @@ public function buildView(FormView $view, FormInterface $form, array $options) */ public function getParent() { - return __NAMESPACE__.'\TextType'; + return TextType::class; } /** diff --git a/Extension/Core/Type/TimezoneType.php b/Extension/Core/Type/TimezoneType.php index be03a9baf2..0f0157f6be 100644 --- a/Extension/Core/Type/TimezoneType.php +++ b/Extension/Core/Type/TimezoneType.php @@ -89,7 +89,7 @@ public function configureOptions(OptionsResolver $resolver) */ public function getParent() { - return __NAMESPACE__.'\ChoiceType'; + return ChoiceType::class; } /** diff --git a/Extension/Core/Type/UrlType.php b/Extension/Core/Type/UrlType.php index 39b9d2d208..b0392a9849 100644 --- a/Extension/Core/Type/UrlType.php +++ b/Extension/Core/Type/UrlType.php @@ -56,7 +56,7 @@ public function configureOptions(OptionsResolver $resolver) */ public function getParent() { - return __NAMESPACE__.'\TextType'; + return TextType::class; } /** diff --git a/Extension/Validator/Constraints/FormValidator.php b/Extension/Validator/Constraints/FormValidator.php index 747273f88f..e0885eae6b 100644 --- a/Extension/Validator/Constraints/FormValidator.php +++ b/Extension/Validator/Constraints/FormValidator.php @@ -30,7 +30,7 @@ class FormValidator extends ConstraintValidator public function validate($form, Constraint $formConstraint) { if (!$formConstraint instanceof Form) { - throw new UnexpectedTypeException($formConstraint, __NAMESPACE__.'\Form'); + throw new UnexpectedTypeException($formConstraint, Form::class); } if (!$form instanceof FormInterface) { diff --git a/Tests/Fixtures/FooSubType.php b/Tests/Fixtures/FooSubType.php index 9ce8b5e66e..c4cfde2274 100644 --- a/Tests/Fixtures/FooSubType.php +++ b/Tests/Fixtures/FooSubType.php @@ -17,6 +17,6 @@ class FooSubType extends AbstractType { public function getParent(): ?string { - return __NAMESPACE__.'\FooType'; + return FooType::class; } } diff --git a/Tests/Fixtures/FooTypeBarExtension.php b/Tests/Fixtures/FooTypeBarExtension.php index fbe1601d5b..70c710e922 100644 --- a/Tests/Fixtures/FooTypeBarExtension.php +++ b/Tests/Fixtures/FooTypeBarExtension.php @@ -30,6 +30,6 @@ public function getAllowedOptionValues() public static function getExtendedTypes(): iterable { - return [__NAMESPACE__.'\FooType']; + return [FooType::class]; } } diff --git a/Tests/Fixtures/FooTypeBazExtension.php b/Tests/Fixtures/FooTypeBazExtension.php index 250c122f9c..a11f158844 100644 --- a/Tests/Fixtures/FooTypeBazExtension.php +++ b/Tests/Fixtures/FooTypeBazExtension.php @@ -23,6 +23,6 @@ public function buildForm(FormBuilderInterface $builder, array $options) public static function getExtendedTypes(): iterable { - return [__NAMESPACE__.'\FooType']; + return [FooType::class]; } } diff --git a/Tests/ResolvedFormTypeTest.php b/Tests/ResolvedFormTypeTest.php index b24c9cf9f9..e4c4c97485 100644 --- a/Tests/ResolvedFormTypeTest.php +++ b/Tests/ResolvedFormTypeTest.php @@ -376,12 +376,12 @@ public function testBlockPrefixDefaultsToFQCNIfNoName($typeClass, $blockPrefix) public function provideTypeClassBlockPrefixTuples() { return [ - [__NAMESPACE__.'\Fixtures\FooType', 'foo'], - [__NAMESPACE__.'\Fixtures\Foo', 'foo'], - [__NAMESPACE__.'\Fixtures\Type', 'type'], - [__NAMESPACE__.'\Fixtures\FooBarHTMLType', 'foo_bar_html'], + [Fixtures\FooType::class, 'foo'], + [Fixtures\Foo::class, 'foo'], + [Fixtures\Type::class, 'type'], + [Fixtures\FooBarHTMLType::class, 'foo_bar_html'], [__NAMESPACE__.'\Fixtures\Foo1Bar2Type', 'foo1_bar2'], - [__NAMESPACE__.'\Fixtures\FBooType', 'f_boo'], + [Fixtures\FBooType::class, 'f_boo'], ]; }