From 1bedc6e14316d836c7718def70c06397de3faf8e Mon Sep 17 00:00:00 2001 From: zeljko Date: Thu, 4 Jan 2024 15:56:15 +0100 Subject: [PATCH] Fixed compatibility with symfony/forms ^6.3 --- .../Component/Form/AbstractType.stubphp | 22 +++++++++++++++++++ .../Form/AbstractTypeExtension.stubphp | 22 +++++++++++++++++++ src/Stubs/common/Component/Form/Form.stubphp | 1 + .../Form/FormBuilderInterface.stubphp | 1 + .../Component/Form/FormInterface.stubphp | 2 ++ .../Component/Form/FormTypeInterface.stubphp | 2 ++ .../common/Component/Form/FormView.stubphp | 9 ++++---- .../forms/AbstractTypeExtension.feature | 2 ++ .../acceptance/forms/FormView.feature | 5 ++--- 9 files changed, 58 insertions(+), 8 deletions(-) diff --git a/src/Stubs/common/Component/Form/AbstractType.stubphp b/src/Stubs/common/Component/Form/AbstractType.stubphp index b495ea36..094eab0d 100644 --- a/src/Stubs/common/Component/Form/AbstractType.stubphp +++ b/src/Stubs/common/Component/Form/AbstractType.stubphp @@ -8,4 +8,26 @@ namespace Symfony\Component\Form; */ abstract class AbstractType implements FormTypeInterface { + /** + * @param FormBuilderInterface $builder + * + * @return void + */ + public function buildForm(FormBuilderInterface $builder, array $options){} + + /** + * @param FormInterface $form + * @param FormView $view + * + * @return void + */ + public function buildView(FormView $view, FormInterface $form, array $options){} + + /** + * @param FormInterface $form + * @param FormView $view + * + * @return void + */ + public function finishView(FormView $view, FormInterface $form, array $options){} } diff --git a/src/Stubs/common/Component/Form/AbstractTypeExtension.stubphp b/src/Stubs/common/Component/Form/AbstractTypeExtension.stubphp index 434b80a8..59abdb05 100644 --- a/src/Stubs/common/Component/Form/AbstractTypeExtension.stubphp +++ b/src/Stubs/common/Component/Form/AbstractTypeExtension.stubphp @@ -8,4 +8,26 @@ namespace Symfony\Component\Form; */ abstract class AbstractTypeExtension implements FormTypeExtensionInterface { + /** + * @param FormBuilderInterface $builder + * + * @return void + */ + public function buildForm(FormBuilderInterface $builder, array $options){} + + /** + * @param FormInterface $form + * @param FormView $view + * + * @return void + */ + public function buildView(FormView $view, FormInterface $form, array $options){} + + /** + * @param FormInterface $form + * @param FormView $view + * + * @return void + */ + public function finishView(FormView $view, FormInterface $form, array $options){} } diff --git a/src/Stubs/common/Component/Form/Form.stubphp b/src/Stubs/common/Component/Form/Form.stubphp index d271f8da..1b264b0c 100644 --- a/src/Stubs/common/Component/Form/Form.stubphp +++ b/src/Stubs/common/Component/Form/Form.stubphp @@ -5,6 +5,7 @@ namespace Symfony\Component\Form; /** * @template T * @implements FormInterface + * @implements \IteratorAggregate */ class Form implements \IteratorAggregate, FormInterface, ClearableErrorsInterface { diff --git a/src/Stubs/common/Component/Form/FormBuilderInterface.stubphp b/src/Stubs/common/Component/Form/FormBuilderInterface.stubphp index 309930e3..210d2964 100644 --- a/src/Stubs/common/Component/Form/FormBuilderInterface.stubphp +++ b/src/Stubs/common/Component/Form/FormBuilderInterface.stubphp @@ -6,6 +6,7 @@ use Symfony\Component\Form\FormTypeInterface; /** * @template T + * @template-extends \Traversable * @template-extends FormConfigBuilderInterface */ interface FormBuilderInterface extends \Traversable, \Countable, FormConfigBuilderInterface diff --git a/src/Stubs/common/Component/Form/FormInterface.stubphp b/src/Stubs/common/Component/Form/FormInterface.stubphp index 6fac3e9e..388ac7e1 100644 --- a/src/Stubs/common/Component/Form/FormInterface.stubphp +++ b/src/Stubs/common/Component/Form/FormInterface.stubphp @@ -5,6 +5,8 @@ namespace Symfony\Component\Form; /** * @template T * @method void clearErrors(bool $deep) + * @extends \ArrayAccess + * @extends \Traversable */ interface FormInterface extends \ArrayAccess, \Traversable, \Countable { diff --git a/src/Stubs/common/Component/Form/FormTypeInterface.stubphp b/src/Stubs/common/Component/Form/FormTypeInterface.stubphp index cd06d425..1ff649b4 100644 --- a/src/Stubs/common/Component/Form/FormTypeInterface.stubphp +++ b/src/Stubs/common/Component/Form/FormTypeInterface.stubphp @@ -6,6 +6,8 @@ use Symfony\Component\OptionsResolver\OptionsResolver; /** * @template T + * @implements \ArrayAccess + * @implements \IteratorAggregate */ interface FormTypeInterface { diff --git a/src/Stubs/common/Component/Form/FormView.stubphp b/src/Stubs/common/Component/Form/FormView.stubphp index d92f09a9..eee7ef4b 100644 --- a/src/Stubs/common/Component/Form/FormView.stubphp +++ b/src/Stubs/common/Component/Form/FormView.stubphp @@ -6,14 +6,13 @@ use Symfony\Component\Form\Exception\BadMethodCallException; /** * @template T + * @implements \ArrayAccess + * @implements \IteratorAggregate */ class FormView implements \ArrayAccess, \IteratorAggregate, \Countable { /** - * @psalm-suppress MixedArrayAssignment - * @psalm-suppress InvalidArrayOffset - * - * @psalm-var array{value: ?T, attr: array}&array + * @psalm-var array{value: ?T, attr: array, ...} */ public array $vars = [ 'value' => null, @@ -26,7 +25,7 @@ class FormView implements \ArrayAccess, \IteratorAggregate, \Countable public $parent; /** - * @psalm-var array + * @psalm-var array */ public $children = []; } diff --git a/tests/acceptance/acceptance/forms/AbstractTypeExtension.feature b/tests/acceptance/acceptance/forms/AbstractTypeExtension.feature index baf5eee4..2ca266f5 100644 --- a/tests/acceptance/acceptance/forms/AbstractTypeExtension.feature +++ b/tests/acceptance/acceptance/forms/AbstractTypeExtension.feature @@ -11,6 +11,7 @@ Feature: FormType templates use Symfony\Component\Form\AbstractTypeExtension; use Symfony\Component\Form\Extension\Core\Type\FormType; + /** @extends AbstractTypeExtension */ class TestExtension extends AbstractTypeExtension { public static function getExtendedTypes(): iterable @@ -30,6 +31,7 @@ Feature: FormType templates use Symfony\Component\Form\AbstractTypeExtension; use Symfony\Component\Form\Extension\Core\Type\FormType; + /** @extends AbstractTypeExtension */ class TestExtension extends AbstractTypeExtension { public static function getExtendedTypes(): iterable diff --git a/tests/acceptance/acceptance/forms/FormView.feature b/tests/acceptance/acceptance/forms/FormView.feature index 68dae868..bd4858bd 100644 --- a/tests/acceptance/acceptance/forms/FormView.feature +++ b/tests/acceptance/acceptance/forms/FormView.feature @@ -42,8 +42,7 @@ Feature: Form view Then I see these errors | Type | Message | | Trace | $parentView: Symfony\Component\Form\FormView\|null | - | Trace | $children: array | + | Trace | $children: array | | Trace | $viewData: User\|null | - | Trace | $attr: array | + | Trace | $attr: array | And I see no other errors -