Skip to content

Commit 79002e4

Browse files
derrabusnicolas-grekas
authored andcommitted
[Form] Add missing return types to interfaces
1 parent 4bbda01 commit 79002e4

8 files changed

+49
-10
lines changed

DataMapperInterface.php

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,10 @@ interface DataMapperInterface
2222
* The method is responsible for calling {@link FormInterface::setData()}
2323
* on the children of compound forms, defining their underlying model data.
2424
*
25-
* @param mixed $viewData View data of the compound form being initialized
26-
* @param FormInterface[]|\Traversable $forms A list of {@link FormInterface} instances
25+
* @param mixed $viewData View data of the compound form being initialized
26+
* @param \Traversable<mixed, FormInterface> $forms A list of {@link FormInterface} instances
27+
*
28+
* @return void
2729
*
2830
* @throws Exception\UnexpectedTypeException if the type of the data parameter is not supported
2931
*/
@@ -52,9 +54,11 @@ public function mapDataToForms(mixed $viewData, \Traversable $forms);
5254
* The model data can be an array or an object, so this second argument is always passed
5355
* by reference.
5456
*
55-
* @param FormInterface[]|\Traversable $forms A list of {@link FormInterface} instances
56-
* @param mixed $viewData The compound form's view data that get mapped
57-
* its children model data
57+
* @param \Traversable<mixed, FormInterface> $forms A list of {@link FormInterface} instances
58+
* @param mixed &$viewData The compound form's view data that get mapped
59+
* its children model data
60+
*
61+
* @return void
5862
*
5963
* @throws Exception\UnexpectedTypeException if the type of the data parameter is not supported
6064
*/

Extension/DataCollector/FormDataCollectorInterface.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,26 +25,36 @@ interface FormDataCollectorInterface extends DataCollectorInterface
2525
{
2626
/**
2727
* Stores configuration data of the given form and its children.
28+
*
29+
* @return void
2830
*/
2931
public function collectConfiguration(FormInterface $form);
3032

3133
/**
3234
* Stores the default data of the given form and its children.
35+
*
36+
* @return void
3337
*/
3438
public function collectDefaultData(FormInterface $form);
3539

3640
/**
3741
* Stores the submitted data of the given form and its children.
42+
*
43+
* @return void
3844
*/
3945
public function collectSubmittedData(FormInterface $form);
4046

4147
/**
4248
* Stores the view variables of the given form view and its children.
49+
*
50+
* @return void
4351
*/
4452
public function collectViewVariables(FormView $view);
4553

4654
/**
4755
* Specifies that the given objects represent the same conceptual form.
56+
*
57+
* @return void
4858
*/
4959
public function associateFormWithView(FormInterface $form, FormView $view);
5060

@@ -53,6 +63,8 @@ public function associateFormWithView(FormInterface $form, FormView $view);
5363
* a tree-like data structure.
5464
*
5565
* The result can be queried using {@link getData()}.
66+
*
67+
* @return void
5668
*/
5769
public function buildPreliminaryFormTree(FormInterface $form);
5870

@@ -73,6 +85,8 @@ public function buildPreliminaryFormTree(FormInterface $form);
7385
* tree, only the view data will be included in the result. If a
7486
* corresponding {@link FormInterface} exists otherwise, call
7587
* {@link associateFormWithView()} before calling this method.
88+
*
89+
* @return void
7690
*/
7791
public function buildFinalFormTree(FormInterface $form, FormView $view);
7892

FormRendererEngineInterface.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ interface FormRendererEngineInterface
2424
* @param FormView $view The view to assign the theme(s) to
2525
* @param mixed $themes The theme(s). The type of these themes
2626
* is open to the implementation.
27+
*
28+
* @return void
2729
*/
2830
public function setTheme(FormView $view, mixed $themes, bool $useDefaultThemes = true);
2931

FormRendererInterface.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ public function getEngine(): FormRendererEngineInterface;
3131
* is open to the implementation.
3232
* @param bool $useDefaultThemes If true, will use default themes specified
3333
* in the renderer
34+
*
35+
* @return void
3436
*/
3537
public function setTheme(FormView $view, mixed $themes, bool $useDefaultThemes = true);
3638

FormTypeExtensionInterface.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ interface FormTypeExtensionInterface
2626
*
2727
* @param array<string, mixed> $options
2828
*
29+
* @return void
30+
*
2931
* @see FormTypeInterface::buildForm()
3032
*/
3133
public function buildForm(FormBuilderInterface $builder, array $options);
@@ -38,6 +40,8 @@ public function buildForm(FormBuilderInterface $builder, array $options);
3840
*
3941
* @param array<string, mixed> $options
4042
*
43+
* @return void
44+
*
4145
* @see FormTypeInterface::buildView()
4246
*/
4347
public function buildView(FormView $view, FormInterface $form, array $options);
@@ -50,10 +54,15 @@ public function buildView(FormView $view, FormInterface $form, array $options);
5054
*
5155
* @param array<string, mixed> $options
5256
*
57+
* @return void
58+
*
5359
* @see FormTypeInterface::finishView()
5460
*/
5561
public function finishView(FormView $view, FormInterface $form, array $options);
5662

63+
/**
64+
* @return void
65+
*/
5766
public function configureOptions(OptionsResolver $resolver);
5867

5968
/**

RequestHandlerInterface.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ interface RequestHandlerInterface
2020
{
2121
/**
2222
* Submits a form if it was submitted.
23+
*
24+
* @return void
2325
*/
2426
public function handleRequest(FormInterface $form, mixed $request = null);
2527

ResolvedFormTypeInterface.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,20 +56,26 @@ public function createView(FormInterface $form, FormView $parent = null): FormVi
5656

5757
/**
5858
* Configures a form builder for the type hierarchy.
59+
*
60+
* @return void
5961
*/
6062
public function buildForm(FormBuilderInterface $builder, array $options);
6163

6264
/**
6365
* Configures a form view for the type hierarchy.
6466
*
6567
* It is called before the children of the view are built.
68+
*
69+
* @return void
6670
*/
6771
public function buildView(FormView $view, FormInterface $form, array $options);
6872

6973
/**
7074
* Finishes a form view for the type hierarchy.
7175
*
7276
* It is called after the children of the view have been built.
77+
*
78+
* @return void
7379
*/
7480
public function finishView(FormView $view, FormInterface $form, array $options);
7581

Tests/Extension/Core/Type/FormTypeTest.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -883,14 +883,14 @@ public function getCurrency()
883883

884884
class MoneyDataMapper implements DataMapperInterface
885885
{
886-
public function mapDataToForms($data, $forms)
886+
public function mapDataToForms(mixed $viewData, \Traversable $forms): void
887887
{
888888
$forms = iterator_to_array($forms);
889-
$forms['amount']->setData($data ? $data->getAmount() : 0);
890-
$forms['currency']->setData($data ? $data->getCurrency() : 'EUR');
889+
$forms['amount']->setData($viewData ? $viewData->getAmount() : 0);
890+
$forms['currency']->setData($viewData ? $viewData->getCurrency() : 'EUR');
891891
}
892892

893-
public function mapFormsToData($forms, &$data)
893+
public function mapFormsToData(\Traversable $forms, mixed &$viewData): void
894894
{
895895
$forms = iterator_to_array($forms);
896896

@@ -902,7 +902,7 @@ public function mapFormsToData($forms, &$data)
902902
throw $failure;
903903
}
904904

905-
$data = new Money(
905+
$viewData = new Money(
906906
$forms['amount']->getData(),
907907
$forms['currency']->getData()
908908
);

0 commit comments

Comments
 (0)