Skip to content

Commit afd8c59

Browse files
committed
minor #41869 [Form] better form doc types to support static analysis (Tobion)
This PR was merged into the 4.4 branch. Discussion ---------- [Form] better form doc types to support static analysis | Q | A | ------------- | --- | Branch? | 4.4 | Bug fix? | no | New feature? | no <!-- please update src/**/CHANGELOG.md files --> | Deprecations? | no <!-- please update UPGRADE-*.md and src/**/CHANGELOG.md files --> | Tickets | <!-- prefix each issue number with "Fix #", no need to create an issue if none exist, explain below instead --> | License | MIT | Doc PR | otherwise phpstan will complain in custom FormTypes like ``` class RegistrationFormType extends AbstractType { public function buildForm(FormBuilderInterface $builder, array $options): void ````` that it does not know what the iterable $builder and $options are about. Commits ------- 56900d2b24 [Form] better form doc types to support static analysis
2 parents c0b7a80 + 6116bbc commit afd8c59

File tree

3 files changed

+14
-4
lines changed

3 files changed

+14
-4
lines changed

FormBuilderInterface.php

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313

1414
/**
1515
* @author Bernhard Schussek <[email protected]>
16+
*
17+
* @extends \Traversable<string, self>
1618
*/
1719
interface FormBuilderInterface extends \Traversable, \Countable, FormConfigBuilderInterface
1820
{
@@ -25,6 +27,7 @@ interface FormBuilderInterface extends \Traversable, \Countable, FormConfigBuild
2527
*
2628
* @param string|FormBuilderInterface $child
2729
* @param string|null $type
30+
* @param array<string, mixed> $options
2831
*
2932
* @return self
3033
*/
@@ -33,8 +36,9 @@ public function add($child, $type = null, array $options = []);
3336
/**
3437
* Creates a form builder.
3538
*
36-
* @param string $name The name of the form or the name of the property
37-
* @param string|null $type The type of the form or null if name is a property
39+
* @param string $name The name of the form or the name of the property
40+
* @param string|null $type The type of the form or null if name is a property
41+
* @param array<string, mixed> $options
3842
*
3943
* @return self
4044
*/
@@ -72,7 +76,7 @@ public function has($name);
7276
/**
7377
* Returns the children.
7478
*
75-
* @return array
79+
* @return array<string, self>
7680
*/
7781
public function all();
7882

FormConfigInterface.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,7 @@ public function getAutoInitialize();
229229
/**
230230
* Returns all options passed during the construction of the form.
231231
*
232-
* @return array The passed options
232+
* @return array<string, mixed> The passed options
233233
*/
234234
public function getOptions();
235235

FormTypeInterface.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ interface FormTypeInterface
2424
* This method is called for each type in the hierarchy starting from the
2525
* top most type. Type extensions can further modify the form.
2626
*
27+
* @param array<string, mixed> $options
28+
*
2729
* @see FormTypeExtensionInterface::buildForm()
2830
*/
2931
public function buildForm(FormBuilderInterface $builder, array $options);
@@ -38,6 +40,8 @@ public function buildForm(FormBuilderInterface $builder, array $options);
3840
* This means that you cannot access child views in this method. If you need
3941
* to do so, move your logic to {@link finishView()} instead.
4042
*
43+
* @param array<string, mixed> $options
44+
*
4145
* @see FormTypeExtensionInterface::buildView()
4246
*/
4347
public function buildView(FormView $view, FormInterface $form, array $options);
@@ -53,6 +57,8 @@ public function buildView(FormView $view, FormInterface $form, array $options);
5357
* such logic in this method that actually accesses child views. For everything
5458
* else you are recommended to implement {@link buildView()} instead.
5559
*
60+
* @param array<string, mixed> $options
61+
*
5662
* @see FormTypeExtensionInterface::finishView()
5763
*/
5864
public function finishView(FormView $view, FormInterface $form, array $options);

0 commit comments

Comments
 (0)