[Form] better form doc types to support static analysis

This commit is contained in:
Tobias Schultze 2021-06-26 20:16:56 +02:00
parent 6713ab3291
commit 56900d2b24
3 changed files with 14 additions and 4 deletions

View File

@ -13,6 +13,8 @@ namespace Symfony\Component\Form;
/** /**
* @author Bernhard Schussek <bschussek@gmail.com> * @author Bernhard Schussek <bschussek@gmail.com>
*
* @extends \Traversable<string, self>
*/ */
interface FormBuilderInterface extends \Traversable, \Countable, FormConfigBuilderInterface interface FormBuilderInterface extends \Traversable, \Countable, FormConfigBuilderInterface
{ {
@ -25,6 +27,7 @@ interface FormBuilderInterface extends \Traversable, \Countable, FormConfigBuild
* *
* @param string|FormBuilderInterface $child * @param string|FormBuilderInterface $child
* @param string|null $type * @param string|null $type
* @param array<string, mixed> $options
* *
* @return self * @return self
*/ */
@ -33,8 +36,9 @@ interface FormBuilderInterface extends \Traversable, \Countable, FormConfigBuild
/** /**
* Creates a form builder. * Creates a form builder.
* *
* @param string $name The name of the form or the name of the property * @param string $name The name of the form or the name of the property
* @param string|null $type The type of the form or null if name is a property * @param string|null $type The type of the form or null if name is a property
* @param array<string, mixed> $options
* *
* @return self * @return self
*/ */
@ -72,7 +76,7 @@ interface FormBuilderInterface extends \Traversable, \Countable, FormConfigBuild
/** /**
* Returns the children. * Returns the children.
* *
* @return array * @return array<string, self>
*/ */
public function all(); public function all();

View File

@ -229,7 +229,7 @@ interface FormConfigInterface
/** /**
* Returns all options passed during the construction of the form. * Returns all options passed during the construction of the form.
* *
* @return array The passed options * @return array<string, mixed> The passed options
*/ */
public function getOptions(); public function getOptions();

View File

@ -24,6 +24,8 @@ interface FormTypeInterface
* This method is called for each type in the hierarchy starting from the * This method is called for each type in the hierarchy starting from the
* top most type. Type extensions can further modify the form. * top most type. Type extensions can further modify the form.
* *
* @param array<string, mixed> $options
*
* @see FormTypeExtensionInterface::buildForm() * @see FormTypeExtensionInterface::buildForm()
*/ */
public function buildForm(FormBuilderInterface $builder, array $options); public function buildForm(FormBuilderInterface $builder, array $options);
@ -38,6 +40,8 @@ interface FormTypeInterface
* This means that you cannot access child views in this method. If you need * This means that you cannot access child views in this method. If you need
* to do so, move your logic to {@link finishView()} instead. * to do so, move your logic to {@link finishView()} instead.
* *
* @param array<string, mixed> $options
*
* @see FormTypeExtensionInterface::buildView() * @see FormTypeExtensionInterface::buildView()
*/ */
public function buildView(FormView $view, FormInterface $form, array $options); public function buildView(FormView $view, FormInterface $form, array $options);
@ -53,6 +57,8 @@ interface FormTypeInterface
* such logic in this method that actually accesses child views. For everything * such logic in this method that actually accesses child views. For everything
* else you are recommended to implement {@link buildView()} instead. * else you are recommended to implement {@link buildView()} instead.
* *
* @param array<string, mixed> $options
*
* @see FormTypeExtensionInterface::finishView() * @see FormTypeExtensionInterface::finishView()
*/ */
public function finishView(FormView $view, FormInterface $form, array $options); public function finishView(FormView $view, FormInterface $form, array $options);