Skip to content

Commit

Permalink
Merge branch '4.4' into 5.0
Browse files Browse the repository at this point in the history
* 4.4:
  Use `::class` constants instead of `__NAMESPACE__` when possible
  • Loading branch information
nicolas-grekas committed Dec 16, 2019
2 parents 62afdbd + 7ed4441 commit c57a9fe
Show file tree
Hide file tree
Showing 24 changed files with 30 additions and 30 deletions.
2 changes: 1 addition & 1 deletion Extension/Core/Type/BirthdayType.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public function configureOptions(OptionsResolver $resolver)
*/
public function getParent()
{
return __NAMESPACE__.'\DateType';
return DateType::class;
}

/**
Expand Down
4 changes: 2 additions & 2 deletions Extension/Core/Type/ChoiceType.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion Extension/Core/Type/CollectionType.php
Original file line number Diff line number Diff line change
Expand Up @@ -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,
]);
Expand Down
2 changes: 1 addition & 1 deletion Extension/Core/Type/CountryType.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public function configureOptions(OptionsResolver $resolver)
*/
public function getParent()
{
return __NAMESPACE__.'\ChoiceType';
return ChoiceType::class;
}

/**
Expand Down
2 changes: 1 addition & 1 deletion Extension/Core/Type/CurrencyType.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public function configureOptions(OptionsResolver $resolver)
*/
public function getParent()
{
return __NAMESPACE__.'\ChoiceType';
return ChoiceType::class;
}

/**
Expand Down
4 changes: 2 additions & 2 deletions Extension/Core/Type/DateTimeType.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)
;
}

Expand Down
2 changes: 1 addition & 1 deletion Extension/Core/Type/EmailType.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class EmailType extends AbstractType
*/
public function getParent()
{
return __NAMESPACE__.'\TextType';
return TextType::class;
}

/**
Expand Down
2 changes: 1 addition & 1 deletion Extension/Core/Type/LanguageType.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public function configureOptions(OptionsResolver $resolver)
*/
public function getParent()
{
return __NAMESPACE__.'\ChoiceType';
return ChoiceType::class;
}

/**
Expand Down
2 changes: 1 addition & 1 deletion Extension/Core/Type/LocaleType.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public function configureOptions(OptionsResolver $resolver)
*/
public function getParent()
{
return __NAMESPACE__.'\ChoiceType';
return ChoiceType::class;
}

/**
Expand Down
2 changes: 1 addition & 1 deletion Extension/Core/Type/PasswordType.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public function configureOptions(OptionsResolver $resolver)
*/
public function getParent()
{
return __NAMESPACE__.'\TextType';
return TextType::class;
}

/**
Expand Down
2 changes: 1 addition & 1 deletion Extension/Core/Type/RadioType.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class RadioType extends AbstractType
*/
public function getParent()
{
return __NAMESPACE__.'\CheckboxType';
return CheckboxType::class;
}

/**
Expand Down
2 changes: 1 addition & 1 deletion Extension/Core/Type/RangeType.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class RangeType extends AbstractType
*/
public function getParent()
{
return __NAMESPACE__.'\TextType';
return TextType::class;
}

/**
Expand Down
2 changes: 1 addition & 1 deletion Extension/Core/Type/RepeatedType.php
Original file line number Diff line number Diff line change
Expand Up @@ -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' => [],
Expand Down
2 changes: 1 addition & 1 deletion Extension/Core/Type/ResetType.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class ResetType extends AbstractType implements ButtonTypeInterface
*/
public function getParent()
{
return __NAMESPACE__.'\ButtonType';
return ButtonType::class;
}

/**
Expand Down
2 changes: 1 addition & 1 deletion Extension/Core/Type/SearchType.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class SearchType extends AbstractType
*/
public function getParent()
{
return __NAMESPACE__.'\TextType';
return TextType::class;
}

/**
Expand Down
2 changes: 1 addition & 1 deletion Extension/Core/Type/SubmitType.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public function configureOptions(OptionsResolver $resolver)
*/
public function getParent()
{
return __NAMESPACE__.'\ButtonType';
return ButtonType::class;
}

/**
Expand Down
2 changes: 1 addition & 1 deletion Extension/Core/Type/TextareaType.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public function buildView(FormView $view, FormInterface $form, array $options)
*/
public function getParent()
{
return __NAMESPACE__.'\TextType';
return TextType::class;
}

/**
Expand Down
2 changes: 1 addition & 1 deletion Extension/Core/Type/TimezoneType.php
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ public function configureOptions(OptionsResolver $resolver)
*/
public function getParent()
{
return __NAMESPACE__.'\ChoiceType';
return ChoiceType::class;
}

/**
Expand Down
2 changes: 1 addition & 1 deletion Extension/Core/Type/UrlType.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public function configureOptions(OptionsResolver $resolver)
*/
public function getParent()
{
return __NAMESPACE__.'\TextType';
return TextType::class;
}

/**
Expand Down
2 changes: 1 addition & 1 deletion Extension/Validator/Constraints/FormValidator.php
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion Tests/Fixtures/FooSubType.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,6 @@ class FooSubType extends AbstractType
{
public function getParent(): ?string
{
return __NAMESPACE__.'\FooType';
return FooType::class;
}
}
2 changes: 1 addition & 1 deletion Tests/Fixtures/FooTypeBarExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,6 @@ public function getAllowedOptionValues()

public static function getExtendedTypes(): iterable
{
return [__NAMESPACE__.'\FooType'];
return [FooType::class];
}
}
2 changes: 1 addition & 1 deletion Tests/Fixtures/FooTypeBazExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,6 @@ public function buildForm(FormBuilderInterface $builder, array $options)

public static function getExtendedTypes(): iterable
{
return [__NAMESPACE__.'\FooType'];
return [FooType::class];
}
}
10 changes: 5 additions & 5 deletions Tests/ResolvedFormTypeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'],
];
}

Expand Down

0 comments on commit c57a9fe

Please sign in to comment.