Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed compatibility with symfony/forms ^6.3 #329

Open
wants to merge 3 commits into
base: 5.x
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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,9 +11,7 @@ Feature: FormType templates
use Symfony\Component\Form\AbstractTypeExtension;
use Symfony\Component\Form\Extension\Core\Type\FormType;

/**
* @extends AbstractTypeExtension<string>
*/
/** @extends AbstractTypeExtension<void> */
class TestExtension extends AbstractTypeExtension
{
public static function getExtendedTypes(): iterable
Expand All @@ -33,9 +31,7 @@ Feature: FormType templates
use Symfony\Component\Form\AbstractTypeExtension;
use Symfony\Component\Form\Extension\Core\Type\FormType;

/**
* @extends AbstractTypeExtension<string>
*/
/** @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