Skip to content

Commit

Permalink
Fixed compatibility with symfony/forms ^6.3
Browse files Browse the repository at this point in the history
  • Loading branch information
zmitic committed Jan 4, 2024
1 parent b9511a3 commit 1bedc6e
Show file tree
Hide file tree
Showing 9 changed files with 58 additions and 8 deletions.
22 changes: 22 additions & 0 deletions src/Stubs/common/Component/Form/AbstractType.stubphp
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,26 @@ namespace Symfony\Component\Form;
*/
abstract class AbstractType implements FormTypeInterface
{
/**
* @param FormBuilderInterface<T> $builder
*
* @return void
*/
public function buildForm(FormBuilderInterface $builder, array $options){}

/**
* @param FormInterface<T> $form
* @param FormView<T> $view
*
* @return void
*/
public function buildView(FormView $view, FormInterface $form, array $options){}

/**
* @param FormInterface<T> $form
* @param FormView<T> $view
*
* @return void
*/
public function finishView(FormView $view, FormInterface $form, array $options){}
}
22 changes: 22 additions & 0 deletions src/Stubs/common/Component/Form/AbstractTypeExtension.stubphp
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,26 @@ namespace Symfony\Component\Form;
*/
abstract class AbstractTypeExtension implements FormTypeExtensionInterface
{
/**
* @param FormBuilderInterface<T> $builder
*
* @return void
*/
public function buildForm(FormBuilderInterface $builder, array $options){}

/**
* @param FormInterface<T> $form
* @param FormView<T> $view
*
* @return void
*/
public function buildView(FormView $view, FormInterface $form, array $options){}

/**
* @param FormInterface<T> $form
* @param FormView<T> $view
*
* @return void
*/
public function finishView(FormView $view, FormInterface $form, array $options){}
}
1 change: 1 addition & 0 deletions src/Stubs/common/Component/Form/Form.stubphp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ namespace Symfony\Component\Form;
/**
* @template T
* @implements FormInterface<T>
* @implements \IteratorAggregate<string, FormInterface>
*/
class Form implements \IteratorAggregate, FormInterface, ClearableErrorsInterface
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ use Symfony\Component\Form\FormTypeInterface;

/**
* @template T
* @template-extends \Traversable<string, FormBuilderInterface>
* @template-extends FormConfigBuilderInterface<T>
*/
interface FormBuilderInterface extends \Traversable, \Countable, FormConfigBuilderInterface
Expand Down
2 changes: 2 additions & 0 deletions src/Stubs/common/Component/Form/FormInterface.stubphp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ namespace Symfony\Component\Form;
/**
* @template T
* @method void clearErrors(bool $deep)
* @extends \ArrayAccess<string, FormInterface>
* @extends \Traversable<string, FormInterface>
*/
interface FormInterface extends \ArrayAccess, \Traversable, \Countable
{
Expand Down
2 changes: 2 additions & 0 deletions src/Stubs/common/Component/Form/FormTypeInterface.stubphp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ use Symfony\Component\OptionsResolver\OptionsResolver;

/**
* @template T
* @implements \ArrayAccess<int|string, FormView>
* @implements \IteratorAggregate<int|string, FormView>
*/
interface FormTypeInterface
{
Expand Down
9 changes: 4 additions & 5 deletions src/Stubs/common/Component/Form/FormView.stubphp
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,13 @@ use Symfony\Component\Form\Exception\BadMethodCallException;

/**
* @template T
* @implements \ArrayAccess<int|string, FormView>
* @implements \IteratorAggregate<int|string, FormView>
*/
class FormView implements \ArrayAccess, \IteratorAggregate, \Countable
{
/**
* @psalm-suppress MixedArrayAssignment
* @psalm-suppress InvalidArrayOffset
*
* @psalm-var array{value: ?T, attr: array<array-key, mixed>}&array<string, mixed>
* @psalm-var array{value: ?T, attr: array<string, mixed>, ...}
*/
public array $vars = [
'value' => null,
Expand All @@ -26,7 +25,7 @@ class FormView implements \ArrayAccess, \IteratorAggregate, \Countable
public $parent;

/**
* @psalm-var array<string, FormView>
* @psalm-var array<int|string, FormView>
*/
public $children = [];
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ Feature: FormType templates
use Symfony\Component\Form\AbstractTypeExtension;
use Symfony\Component\Form\Extension\Core\Type\FormType;
/** @extends AbstractTypeExtension<void> */
class TestExtension extends AbstractTypeExtension
{
public static function getExtendedTypes(): iterable
Expand All @@ -30,6 +31,7 @@ Feature: FormType templates
use Symfony\Component\Form\AbstractTypeExtension;
use Symfony\Component\Form\Extension\Core\Type\FormType;
/** @extends AbstractTypeExtension<void> */
class TestExtension extends AbstractTypeExtension
{
public static function getExtendedTypes(): iterable
Expand Down
5 changes: 2 additions & 3 deletions tests/acceptance/acceptance/forms/FormView.feature
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,7 @@ Feature: Form view
Then I see these errors
| Type | Message |
| Trace | $parentView: Symfony\Component\Form\FormView\|null |
| Trace | $children: array<string, Symfony\Component\Form\FormView> |
| Trace | $children: array<int\|string, Symfony\Component\Form\FormView> |
| Trace | $viewData: User\|null |
| Trace | $attr: array<array-key, mixed> |
| Trace | $attr: array<string, mixed> |
And I see no other errors

0 comments on commit 1bedc6e

Please sign in to comment.