Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 7a8959b

Browse files
minor #51045 [Form] Use logical ordering for type and extension methods (HeahDude)
This PR was merged into the 6.4 branch. Discussion ---------- [Form] Use logical ordering for type and extension methods | Q | A | ------------- | --- | Branch? | 6.4 | Bug fix? | no | New feature? | no | Deprecations? | no | Tickets | ~ | License | MIT | Doc PR | symfony/symfony-docs#18585 Related docs PR has already been merged. IMHO having methods ordered the same way that the component uses them gives a better understanding of how it works (same as having a "supports()" method defined first in a class like `Voter`). It would be nice to reorder them in core implementations as well, by accepting such changes in 5.4, it would not cause conflicts when merging branches, WDYT? Commits ------- 40bfbbd [Form][DX] Use logical ordering for type and extension methods
2 parents ee6a55d + 40bfbbd commit 7a8959b

File tree

5 files changed

+101
-98
lines changed

5 files changed

+101
-98
lines changed

.github/expected-missing-return-types.diff

Lines changed: 57 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -694,7 +694,7 @@ diff --git a/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExt
694694
+ public function load(array $configs, ContainerBuilder $container): void
695695
{
696696
$loader = new PhpFileLoader($container, new FileLocator(\dirname(__DIR__).'/Resources/config'));
697-
@@ -2941,5 +2941,5 @@ class FrameworkExtension extends Extension
697+
@@ -2951,5 +2951,5 @@ class FrameworkExtension extends Extension
698698
* @return void
699699
*/
700700
- public static function registerRateLimiter(ContainerBuilder $container, string $name, array $limiterConfig)
@@ -5315,76 +5315,76 @@ diff --git a/src/Symfony/Component/Form/AbstractType.php b/src/Symfony/Component
53155315
--- a/src/Symfony/Component/Form/AbstractType.php
53165316
+++ b/src/Symfony/Component/Form/AbstractType.php
53175317
@@ -24,5 +24,5 @@ abstract class AbstractType implements FormTypeInterface
5318+
* @return string|null
5319+
*/
5320+
- public function getParent()
5321+
+ public function getParent(): ?string
5322+
{
5323+
return FormType::class;
5324+
@@ -32,5 +32,5 @@ abstract class AbstractType implements FormTypeInterface
5325+
* @return void
5326+
*/
5327+
- public function configureOptions(OptionsResolver $resolver)
5328+
+ public function configureOptions(OptionsResolver $resolver): void
5329+
{
5330+
}
5331+
@@ -39,5 +39,5 @@ abstract class AbstractType implements FormTypeInterface
53185332
* @return void
53195333
*/
53205334
- public function buildForm(FormBuilderInterface $builder, array $options)
53215335
+ public function buildForm(FormBuilderInterface $builder, array $options): void
53225336
{
53235337
}
5324-
@@ -31,5 +31,5 @@ abstract class AbstractType implements FormTypeInterface
5338+
@@ -46,5 +46,5 @@ abstract class AbstractType implements FormTypeInterface
53255339
* @return void
53265340
*/
53275341
- public function buildView(FormView $view, FormInterface $form, array $options)
53285342
+ public function buildView(FormView $view, FormInterface $form, array $options): void
53295343
{
53305344
}
5331-
@@ -38,5 +38,5 @@ abstract class AbstractType implements FormTypeInterface
5345+
@@ -53,5 +53,5 @@ abstract class AbstractType implements FormTypeInterface
53325346
* @return void
53335347
*/
53345348
- public function finishView(FormView $view, FormInterface $form, array $options)
53355349
+ public function finishView(FormView $view, FormInterface $form, array $options): void
53365350
{
53375351
}
5338-
@@ -45,5 +45,5 @@ abstract class AbstractType implements FormTypeInterface
5339-
* @return void
5340-
*/
5341-
- public function configureOptions(OptionsResolver $resolver)
5342-
+ public function configureOptions(OptionsResolver $resolver): void
5343-
{
5344-
}
5345-
@@ -52,5 +52,5 @@ abstract class AbstractType implements FormTypeInterface
5352+
@@ -60,5 +60,5 @@ abstract class AbstractType implements FormTypeInterface
53465353
* @return string
53475354
*/
53485355
- public function getBlockPrefix()
53495356
+ public function getBlockPrefix(): string
53505357
{
53515358
return StringUtil::fqcnToBlockPrefix(static::class) ?: '';
5352-
@@ -60,5 +60,5 @@ abstract class AbstractType implements FormTypeInterface
5353-
* @return string|null
5354-
*/
5355-
- public function getParent()
5356-
+ public function getParent(): ?string
5357-
{
5358-
return FormType::class;
53595359
diff --git a/src/Symfony/Component/Form/AbstractTypeExtension.php b/src/Symfony/Component/Form/AbstractTypeExtension.php
53605360
--- a/src/Symfony/Component/Form/AbstractTypeExtension.php
53615361
+++ b/src/Symfony/Component/Form/AbstractTypeExtension.php
53625362
@@ -22,5 +22,5 @@ abstract class AbstractTypeExtension implements FormTypeExtensionInterface
53635363
* @return void
53645364
*/
5365-
- public function buildForm(FormBuilderInterface $builder, array $options)
5366-
+ public function buildForm(FormBuilderInterface $builder, array $options): void
5365+
- public function configureOptions(OptionsResolver $resolver)
5366+
+ public function configureOptions(OptionsResolver $resolver): void
53675367
{
53685368
}
53695369
@@ -29,5 +29,5 @@ abstract class AbstractTypeExtension implements FormTypeExtensionInterface
53705370
* @return void
53715371
*/
5372-
- public function buildView(FormView $view, FormInterface $form, array $options)
5373-
+ public function buildView(FormView $view, FormInterface $form, array $options): void
5372+
- public function buildForm(FormBuilderInterface $builder, array $options)
5373+
+ public function buildForm(FormBuilderInterface $builder, array $options): void
53745374
{
53755375
}
53765376
@@ -36,5 +36,5 @@ abstract class AbstractTypeExtension implements FormTypeExtensionInterface
53775377
* @return void
53785378
*/
5379-
- public function finishView(FormView $view, FormInterface $form, array $options)
5380-
+ public function finishView(FormView $view, FormInterface $form, array $options): void
5379+
- public function buildView(FormView $view, FormInterface $form, array $options)
5380+
+ public function buildView(FormView $view, FormInterface $form, array $options): void
53815381
{
53825382
}
53835383
@@ -43,5 +43,5 @@ abstract class AbstractTypeExtension implements FormTypeExtensionInterface
53845384
* @return void
53855385
*/
5386-
- public function configureOptions(OptionsResolver $resolver)
5387-
+ public function configureOptions(OptionsResolver $resolver): void
5386+
- public function finishView(FormView $view, FormInterface $form, array $options)
5387+
+ public function finishView(FormView $view, FormInterface $form, array $options): void
53885388
{
53895389
}
53905390
diff --git a/src/Symfony/Component/Form/ButtonBuilder.php b/src/Symfony/Component/Form/ButtonBuilder.php
@@ -6862,33 +6862,33 @@ diff --git a/src/Symfony/Component/Form/FormRendererInterface.php b/src/Symfony/
68626862
diff --git a/src/Symfony/Component/Form/FormTypeExtensionInterface.php b/src/Symfony/Component/Form/FormTypeExtensionInterface.php
68636863
--- a/src/Symfony/Component/Form/FormTypeExtensionInterface.php
68646864
+++ b/src/Symfony/Component/Form/FormTypeExtensionInterface.php
6865-
@@ -31,5 +31,5 @@ interface FormTypeExtensionInterface
6865+
@@ -29,5 +29,5 @@ interface FormTypeExtensionInterface
6866+
* @return void
6867+
*/
6868+
- public function configureOptions(OptionsResolver $resolver);
6869+
+ public function configureOptions(OptionsResolver $resolver): void;
6870+
6871+
/**
6872+
@@ -43,5 +43,5 @@ interface FormTypeExtensionInterface
68666873
* @see FormTypeInterface::buildForm()
68676874
*/
68686875
- public function buildForm(FormBuilderInterface $builder, array $options);
68696876
+ public function buildForm(FormBuilderInterface $builder, array $options): void;
68706877

68716878
/**
6872-
@@ -45,5 +45,5 @@ interface FormTypeExtensionInterface
6879+
@@ -57,5 +57,5 @@ interface FormTypeExtensionInterface
68736880
* @see FormTypeInterface::buildView()
68746881
*/
68756882
- public function buildView(FormView $view, FormInterface $form, array $options);
68766883
+ public function buildView(FormView $view, FormInterface $form, array $options): void;
68776884

68786885
/**
6879-
@@ -59,10 +59,10 @@ interface FormTypeExtensionInterface
6886+
@@ -71,4 +71,4 @@ interface FormTypeExtensionInterface
68806887
* @see FormTypeInterface::finishView()
68816888
*/
68826889
- public function finishView(FormView $view, FormInterface $form, array $options);
68836890
+ public function finishView(FormView $view, FormInterface $form, array $options): void;
6884-
6885-
/**
6886-
* @return void
6887-
*/
6888-
- public function configureOptions(OptionsResolver $resolver);
6889-
+ public function configureOptions(OptionsResolver $resolver): void;
6890-
6891-
/**
6891+
}
68926892
diff --git a/src/Symfony/Component/Form/FormTypeGuesserInterface.php b/src/Symfony/Component/Form/FormTypeGuesserInterface.php
68936893
--- a/src/Symfony/Component/Form/FormTypeGuesserInterface.php
68946894
+++ b/src/Symfony/Component/Form/FormTypeGuesserInterface.php
@@ -6922,46 +6922,46 @@ diff --git a/src/Symfony/Component/Form/FormTypeGuesserInterface.php b/src/Symfo
69226922
diff --git a/src/Symfony/Component/Form/FormTypeInterface.php b/src/Symfony/Component/Form/FormTypeInterface.php
69236923
--- a/src/Symfony/Component/Form/FormTypeInterface.php
69246924
+++ b/src/Symfony/Component/Form/FormTypeInterface.php
6925-
@@ -31,5 +31,5 @@ interface FormTypeInterface
6925+
@@ -27,5 +27,5 @@ interface FormTypeInterface
6926+
* @return string|null
6927+
*/
6928+
- public function getParent();
6929+
+ public function getParent(): ?string;
6930+
6931+
/**
6932+
@@ -34,5 +34,5 @@ interface FormTypeInterface
6933+
* @return void
6934+
*/
6935+
- public function configureOptions(OptionsResolver $resolver);
6936+
+ public function configureOptions(OptionsResolver $resolver): void;
6937+
6938+
/**
6939+
@@ -48,5 +48,5 @@ interface FormTypeInterface
69266940
* @see FormTypeExtensionInterface::buildForm()
69276941
*/
69286942
- public function buildForm(FormBuilderInterface $builder, array $options);
69296943
+ public function buildForm(FormBuilderInterface $builder, array $options): void;
69306944

69316945
/**
6932-
@@ -49,5 +49,5 @@ interface FormTypeInterface
6946+
@@ -66,5 +66,5 @@ interface FormTypeInterface
69336947
* @see FormTypeExtensionInterface::buildView()
69346948
*/
69356949
- public function buildView(FormView $view, FormInterface $form, array $options);
69366950
+ public function buildView(FormView $view, FormInterface $form, array $options): void;
69376951

69386952
/**
6939-
@@ -68,5 +68,5 @@ interface FormTypeInterface
6953+
@@ -85,5 +85,5 @@ interface FormTypeInterface
69406954
* @see FormTypeExtensionInterface::finishView()
69416955
*/
69426956
- public function finishView(FormView $view, FormInterface $form, array $options);
69436957
+ public function finishView(FormView $view, FormInterface $form, array $options): void;
69446958

69456959
/**
6946-
@@ -75,5 +75,5 @@ interface FormTypeInterface
6947-
* @return void
6948-
*/
6949-
- public function configureOptions(OptionsResolver $resolver);
6950-
+ public function configureOptions(OptionsResolver $resolver): void;
6951-
6952-
/**
6953-
@@ -85,5 +85,5 @@ interface FormTypeInterface
6960+
@@ -95,4 +95,4 @@ interface FormTypeInterface
69546961
* @return string
69556962
*/
69566963
- public function getBlockPrefix();
69576964
+ public function getBlockPrefix(): string;
6958-
6959-
/**
6960-
@@ -92,4 +92,4 @@ interface FormTypeInterface
6961-
* @return string|null
6962-
*/
6963-
- public function getParent();
6964-
+ public function getParent(): ?string;
69656965
}
69666966
diff --git a/src/Symfony/Component/Form/FormView.php b/src/Symfony/Component/Form/FormView.php
69676967
--- a/src/Symfony/Component/Form/FormView.php
@@ -8320,7 +8320,7 @@ diff --git a/src/Symfony/Component/HttpKernel/DependencyInjection/LoggerPass.php
83208320
diff --git a/src/Symfony/Component/HttpKernel/DependencyInjection/RegisterControllerArgumentLocatorsPass.php b/src/Symfony/Component/HttpKernel/DependencyInjection/RegisterControllerArgumentLocatorsPass.php
83218321
--- a/src/Symfony/Component/HttpKernel/DependencyInjection/RegisterControllerArgumentLocatorsPass.php
83228322
+++ b/src/Symfony/Component/HttpKernel/DependencyInjection/RegisterControllerArgumentLocatorsPass.php
8323-
@@ -37,5 +37,5 @@ class RegisterControllerArgumentLocatorsPass implements CompilerPassInterface
8323+
@@ -38,5 +38,5 @@ class RegisterControllerArgumentLocatorsPass implements CompilerPassInterface
83248324
* @return void
83258325
*/
83268326
- public function process(ContainerBuilder $container)
@@ -13056,7 +13056,7 @@ diff --git a/src/Symfony/Component/Validator/Constraints/SequentiallyValidator.p
1305613056
diff --git a/src/Symfony/Component/Validator/Constraints/TimeValidator.php b/src/Symfony/Component/Validator/Constraints/TimeValidator.php
1305713057
--- a/src/Symfony/Component/Validator/Constraints/TimeValidator.php
1305813058
+++ b/src/Symfony/Component/Validator/Constraints/TimeValidator.php
13059-
@@ -37,5 +37,5 @@ class TimeValidator extends ConstraintValidator
13059+
@@ -38,5 +38,5 @@ class TimeValidator extends ConstraintValidator
1306013060
* @return void
1306113061
*/
1306213062
- public function validate(mixed $value, Constraint $constraint)

src/Symfony/Component/Form/AbstractType.php

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -21,46 +21,46 @@
2121
abstract class AbstractType implements FormTypeInterface
2222
{
2323
/**
24-
* @return void
24+
* @return string|null
2525
*/
26-
public function buildForm(FormBuilderInterface $builder, array $options)
26+
public function getParent()
2727
{
28+
return FormType::class;
2829
}
2930

3031
/**
3132
* @return void
3233
*/
33-
public function buildView(FormView $view, FormInterface $form, array $options)
34+
public function configureOptions(OptionsResolver $resolver)
3435
{
3536
}
3637

3738
/**
3839
* @return void
3940
*/
40-
public function finishView(FormView $view, FormInterface $form, array $options)
41+
public function buildForm(FormBuilderInterface $builder, array $options)
4142
{
4243
}
4344

4445
/**
4546
* @return void
4647
*/
47-
public function configureOptions(OptionsResolver $resolver)
48+
public function buildView(FormView $view, FormInterface $form, array $options)
4849
{
4950
}
5051

5152
/**
52-
* @return string
53+
* @return void
5354
*/
54-
public function getBlockPrefix()
55+
public function finishView(FormView $view, FormInterface $form, array $options)
5556
{
56-
return StringUtil::fqcnToBlockPrefix(static::class) ?: '';
5757
}
5858

5959
/**
60-
* @return string|null
60+
* @return string
6161
*/
62-
public function getParent()
62+
public function getBlockPrefix()
6363
{
64-
return FormType::class;
64+
return StringUtil::fqcnToBlockPrefix(static::class) ?: '';
6565
}
6666
}

src/Symfony/Component/Form/AbstractTypeExtension.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,28 +21,28 @@ abstract class AbstractTypeExtension implements FormTypeExtensionInterface
2121
/**
2222
* @return void
2323
*/
24-
public function buildForm(FormBuilderInterface $builder, array $options)
24+
public function configureOptions(OptionsResolver $resolver)
2525
{
2626
}
2727

2828
/**
2929
* @return void
3030
*/
31-
public function buildView(FormView $view, FormInterface $form, array $options)
31+
public function buildForm(FormBuilderInterface $builder, array $options)
3232
{
3333
}
3434

3535
/**
3636
* @return void
3737
*/
38-
public function finishView(FormView $view, FormInterface $form, array $options)
38+
public function buildView(FormView $view, FormInterface $form, array $options)
3939
{
4040
}
4141

4242
/**
4343
* @return void
4444
*/
45-
public function configureOptions(OptionsResolver $resolver)
45+
public function finishView(FormView $view, FormInterface $form, array $options)
4646
{
4747
}
4848
}

src/Symfony/Component/Form/FormTypeExtensionInterface.php

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,18 @@
1818
*/
1919
interface FormTypeExtensionInterface
2020
{
21+
/**
22+
* Gets the extended types.
23+
*
24+
* @return string[]
25+
*/
26+
public static function getExtendedTypes(): iterable;
27+
28+
/**
29+
* @return void
30+
*/
31+
public function configureOptions(OptionsResolver $resolver);
32+
2133
/**
2234
* Builds the form.
2335
*
@@ -59,16 +71,4 @@ public function buildView(FormView $view, FormInterface $form, array $options);
5971
* @see FormTypeInterface::finishView()
6072
*/
6173
public function finishView(FormView $view, FormInterface $form, array $options);
62-
63-
/**
64-
* @return void
65-
*/
66-
public function configureOptions(OptionsResolver $resolver);
67-
68-
/**
69-
* Gets the extended types.
70-
*
71-
* @return string[]
72-
*/
73-
public static function getExtendedTypes(): iterable;
7474
}

0 commit comments

Comments
 (0)