mirror of
https://github.com/symfony/form.git
synced 2026-03-24 00:02:23 +01:00
Merge branch '7.4' into 8.0
* 7.4: Fix various typo Revert "minor #61697 [Form] Add better type information using PHPDoc (azjezz)" make test forward compatible
This commit is contained in:
@@ -16,10 +16,6 @@ use Symfony\Component\Form\Util\StringUtil;
|
||||
use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||
|
||||
/**
|
||||
* @template T
|
||||
*
|
||||
* @implements FormTypeInterface<T>
|
||||
*
|
||||
* @author Bernhard Schussek <bschussek@gmail.com>
|
||||
*/
|
||||
abstract class AbstractType implements FormTypeInterface
|
||||
@@ -33,24 +29,15 @@ abstract class AbstractType implements FormTypeInterface
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* @param FormBuilderInterface<T> $builder
|
||||
*/
|
||||
public function buildForm(FormBuilderInterface $builder, array $options): void
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* @param FormView<T> $form
|
||||
* @param FormInterface<T> $view
|
||||
*/
|
||||
public function buildView(FormView $view, FormInterface $form, array $options): void
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* @param FormView<T> $form
|
||||
* @param FormInterface<T> $view
|
||||
*/
|
||||
public function finishView(FormView $view, FormInterface $form, array $options): void
|
||||
{
|
||||
|
||||
@@ -14,10 +14,6 @@ namespace Symfony\Component\Form;
|
||||
use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||
|
||||
/**
|
||||
* @template T
|
||||
*
|
||||
* @implements FormTypeExtensionInterface<T>
|
||||
*
|
||||
* @author Bernhard Schussek <bschussek@gmail.com>
|
||||
*/
|
||||
abstract class AbstractTypeExtension implements FormTypeExtensionInterface
|
||||
@@ -26,25 +22,14 @@ abstract class AbstractTypeExtension implements FormTypeExtensionInterface
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* @param FormBuilderInterface<T> $builder
|
||||
*/
|
||||
public function buildForm(FormBuilderInterface $builder, array $options): void
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* @param FormView<T> $form
|
||||
* @param FormInterface<T> $view
|
||||
*/
|
||||
public function buildView(FormView $view, FormInterface $form, array $options): void
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* @param FormView<T> $form
|
||||
* @param FormInterface<T> $view
|
||||
*/
|
||||
public function finishView(FormView $view, FormInterface $form, array $options): void
|
||||
{
|
||||
}
|
||||
|
||||
@@ -19,10 +19,6 @@ use Symfony\Component\Form\FormEvent;
|
||||
*
|
||||
* It can be used to modify a form depending on the populated data (adding or
|
||||
* removing fields dynamically).
|
||||
*
|
||||
* @template T
|
||||
*
|
||||
* @extends FormEvent<T>
|
||||
*/
|
||||
final class PostSetDataEvent extends FormEvent
|
||||
{
|
||||
|
||||
@@ -19,10 +19,6 @@ use Symfony\Component\Form\FormEvent;
|
||||
* once the model and view data have been denormalized.
|
||||
*
|
||||
* It can be used to fetch data after denormalization.
|
||||
*
|
||||
* @template T
|
||||
*
|
||||
* @extends FormEvent<T>
|
||||
*/
|
||||
final class PostSubmitEvent extends FormEvent
|
||||
{
|
||||
|
||||
@@ -17,10 +17,6 @@ use Symfony\Component\Form\FormEvent;
|
||||
* This event is dispatched at the beginning of the Form::setData() method.
|
||||
*
|
||||
* It can be used to modify the data given during pre-population.
|
||||
*
|
||||
* @template T
|
||||
*
|
||||
* @extends FormEvent<T>
|
||||
*/
|
||||
final class PreSetDataEvent extends FormEvent
|
||||
{
|
||||
|
||||
@@ -19,8 +19,6 @@ use Symfony\Component\Form\FormEvent;
|
||||
* It can be used to:
|
||||
* - Change data from the request, before submitting the data to the form.
|
||||
* - Add or remove form fields, before submitting the data to the form.
|
||||
*
|
||||
* @extends FormEvent<array<string, mixed>>
|
||||
*/
|
||||
final class PreSubmitEvent extends FormEvent
|
||||
{
|
||||
|
||||
@@ -18,10 +18,6 @@ use Symfony\Component\Form\FormEvent;
|
||||
* transforms back the normalized data to the model and view data.
|
||||
*
|
||||
* It can be used to change data from the normalized representation of the data.
|
||||
*
|
||||
* @template T
|
||||
*
|
||||
* @extends FormEvent<T>
|
||||
*/
|
||||
final class SubmitEvent extends FormEvent
|
||||
{
|
||||
|
||||
3
Form.php
3
Form.php
@@ -68,10 +68,7 @@ use Symfony\Component\Validator\Constraints\Traverse;
|
||||
* @author Fabien Potencier <fabien@symfony.com>
|
||||
* @author Bernhard Schussek <bschussek@gmail.com>
|
||||
*
|
||||
* @template T
|
||||
*
|
||||
* @implements \IteratorAggregate<string, FormInterface>
|
||||
* @implements FormInterface<T>
|
||||
*/
|
||||
#[AssertForm]
|
||||
#[Traverse(false)]
|
||||
|
||||
@@ -14,9 +14,6 @@ namespace Symfony\Component\Form;
|
||||
/**
|
||||
* @author Bernhard Schussek <bschussek@gmail.com>
|
||||
*
|
||||
* @template T
|
||||
*
|
||||
* @extends FormConfigBuilderInterface<T>
|
||||
* @extends \Traversable<string, FormBuilderInterface>
|
||||
*/
|
||||
interface FormBuilderInterface extends \Traversable, \Countable, FormConfigBuilderInterface
|
||||
@@ -35,9 +32,9 @@ interface FormBuilderInterface extends \Traversable, \Countable, FormConfigBuild
|
||||
/**
|
||||
* Creates a form builder.
|
||||
*
|
||||
* @param string $name The name of the form or the name of the property
|
||||
* @param class-string<FormTypeInterface>|null $type The type of the form or null if name is a property
|
||||
* @param array<string, mixed> $options
|
||||
* @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 array<string, mixed> $options
|
||||
*/
|
||||
public function create(string $name, ?string $type = null, array $options = []): self;
|
||||
|
||||
@@ -67,8 +64,6 @@ interface FormBuilderInterface extends \Traversable, \Countable, FormConfigBuild
|
||||
|
||||
/**
|
||||
* Creates the form.
|
||||
*
|
||||
* @return FormInterface<T>
|
||||
*/
|
||||
public function getForm(): FormInterface;
|
||||
}
|
||||
|
||||
@@ -13,17 +13,8 @@ namespace Symfony\Component\Form;
|
||||
|
||||
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
|
||||
use Symfony\Component\PropertyAccess\PropertyPathInterface;
|
||||
use Symfony\Component\Form\Event\PreSetDataEvent;
|
||||
use Symfony\Component\Form\Event\PreSubmitEvent;
|
||||
use Symfony\Component\Form\Event\PostSetDataEvent;
|
||||
use Symfony\Component\Form\Event\SubmitEvent;
|
||||
use Symfony\Component\Form\Event\PostSubmitEvent;
|
||||
|
||||
/**
|
||||
* @template T
|
||||
*
|
||||
* @extends FormConfigInterface<T>
|
||||
*
|
||||
* @author Bernhard Schussek <bschussek@gmail.com>
|
||||
*/
|
||||
interface FormConfigBuilderInterface extends FormConfigInterface
|
||||
@@ -31,8 +22,6 @@ interface FormConfigBuilderInterface extends FormConfigInterface
|
||||
/**
|
||||
* Adds an event listener to an event on this form.
|
||||
*
|
||||
* @param FormEvents::* $eventName
|
||||
* @param (callable(PreSetDataEvent<T>): void)|(callable(PostSetDataEvent<T>): void)|(callable(PreSubmitEvent): void)|(callable(SubmitEvent<T>): void)|(callable(PostSubmitEvent<T>): void) $listener
|
||||
* @param int $priority The priority of the listener. Listeners
|
||||
* with a higher priority are called before
|
||||
* listeners with a lower priority.
|
||||
@@ -258,8 +247,6 @@ interface FormConfigBuilderInterface extends FormConfigInterface
|
||||
|
||||
/**
|
||||
* Builds and returns the form configuration.
|
||||
*
|
||||
* @return FormConfigInterface<T>
|
||||
*/
|
||||
public function getFormConfig(): FormConfigInterface;
|
||||
|
||||
|
||||
@@ -17,8 +17,6 @@ use Symfony\Component\PropertyAccess\PropertyPathInterface;
|
||||
/**
|
||||
* The configuration of a {@link Form} object.
|
||||
*
|
||||
* @template T
|
||||
*
|
||||
* @author Bernhard Schussek <bschussek@gmail.com>
|
||||
*/
|
||||
interface FormConfigInterface
|
||||
@@ -132,8 +130,6 @@ interface FormConfigInterface
|
||||
|
||||
/**
|
||||
* Returns the initial data of the form.
|
||||
*
|
||||
* @return T|null
|
||||
*/
|
||||
public function getData(): mixed;
|
||||
|
||||
|
||||
@@ -14,16 +14,10 @@ namespace Symfony\Component\Form;
|
||||
use Symfony\Contracts\EventDispatcher\Event;
|
||||
|
||||
/**
|
||||
* @template T
|
||||
*
|
||||
* @author Bernhard Schussek <bschussek@gmail.com>
|
||||
*/
|
||||
class FormEvent extends Event
|
||||
{
|
||||
/**
|
||||
* @param FormInterface<T> $form The form at the source of the event
|
||||
* @param T $data The data associated with this event
|
||||
*/
|
||||
public function __construct(
|
||||
private FormInterface $form,
|
||||
protected mixed $data,
|
||||
@@ -32,8 +26,6 @@ class FormEvent extends Event
|
||||
|
||||
/**
|
||||
* Returns the form at the source of the event.
|
||||
*
|
||||
* @return FormInterface<T>
|
||||
*/
|
||||
public function getForm(): FormInterface
|
||||
{
|
||||
@@ -42,8 +34,6 @@ class FormEvent extends Event
|
||||
|
||||
/**
|
||||
* Returns the data associated with this event.
|
||||
*
|
||||
* @return T
|
||||
*/
|
||||
public function getData(): mixed
|
||||
{
|
||||
@@ -52,8 +42,6 @@ class FormEvent extends Event
|
||||
|
||||
/**
|
||||
* Allows updating with some filtered data.
|
||||
*
|
||||
* @param T $data The data associated with this event
|
||||
*/
|
||||
public function setData(mixed $data): void
|
||||
{
|
||||
|
||||
@@ -26,12 +26,7 @@ interface FormFactoryInterface
|
||||
*
|
||||
* @see createBuilder()
|
||||
*
|
||||
* @template T
|
||||
*
|
||||
* @param class-string<FormTypeInterface<T>> $type
|
||||
* @param T|null $data The initial data
|
||||
*
|
||||
* @return FormInterface<T>
|
||||
* @param mixed $data The initial data
|
||||
*
|
||||
* @throws InvalidOptionsException if any given option is not applicable to the given type
|
||||
*/
|
||||
@@ -42,12 +37,7 @@ interface FormFactoryInterface
|
||||
*
|
||||
* @see createNamedBuilder()
|
||||
*
|
||||
* @template T
|
||||
*
|
||||
* @param class-string<FormTypeInterface<T>> $type
|
||||
* @param T|null $data The initial data
|
||||
*
|
||||
* @return FormInterface<T>
|
||||
* @param mixed $data The initial data
|
||||
*
|
||||
* @throws InvalidOptionsException if any given option is not applicable to the given type
|
||||
*/
|
||||
@@ -69,12 +59,7 @@ interface FormFactoryInterface
|
||||
/**
|
||||
* Returns a form builder.
|
||||
*
|
||||
* @template T
|
||||
*
|
||||
* @param class-string<FormTypeInterface<T>> $type
|
||||
* @param T|null $data The initial data
|
||||
*
|
||||
* @return FormBuilderInterface<T>
|
||||
* @param mixed $data The initial data
|
||||
*
|
||||
* @throws InvalidOptionsException if any given option is not applicable to the given type
|
||||
*/
|
||||
@@ -83,12 +68,7 @@ interface FormFactoryInterface
|
||||
/**
|
||||
* Returns a form builder.
|
||||
*
|
||||
* @template T
|
||||
*
|
||||
* @param class-string<FormTypeInterface<T>> $type
|
||||
* @param T|null $data The initial data
|
||||
*
|
||||
* @return FormBuilderInterface<T>
|
||||
* @param mixed $data The initial data
|
||||
*
|
||||
* @throws InvalidOptionsException if any given option is not applicable to the given type
|
||||
*/
|
||||
|
||||
@@ -18,8 +18,6 @@ use Symfony\Component\PropertyAccess\PropertyPathInterface;
|
||||
*
|
||||
* @author Bernhard Schussek <bschussek@gmail.com>
|
||||
*
|
||||
* @template T
|
||||
*
|
||||
* @extends \ArrayAccess<string, FormInterface>
|
||||
* @extends \Traversable<string, FormInterface>
|
||||
*/
|
||||
@@ -114,9 +112,9 @@ interface FormInterface extends \ArrayAccess, \Traversable, \Countable
|
||||
/**
|
||||
* Returns the model data in the format needed for the underlying object.
|
||||
*
|
||||
* @return T|null When the field is not submitted, the default data is returned.
|
||||
* When the field is submitted, the default data has been bound
|
||||
* to the submitted view data.
|
||||
* @return mixed When the field is not submitted, the default data is returned.
|
||||
* When the field is submitted, the default data has been bound
|
||||
* to the submitted view data.
|
||||
*
|
||||
* @throws Exception\RuntimeException If the form inherits data but has no parent
|
||||
*/
|
||||
@@ -287,8 +285,5 @@ interface FormInterface extends \ArrayAccess, \Traversable, \Countable
|
||||
*/
|
||||
public function isRoot(): bool;
|
||||
|
||||
/**
|
||||
* @return FormView<T>
|
||||
*/
|
||||
public function createView(?FormView $parent = null): FormView;
|
||||
}
|
||||
|
||||
@@ -14,8 +14,6 @@ namespace Symfony\Component\Form;
|
||||
use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||
|
||||
/**
|
||||
* @template T
|
||||
*
|
||||
* @author Bernhard Schussek <bschussek@gmail.com>
|
||||
*/
|
||||
interface FormTypeExtensionInterface
|
||||
@@ -35,8 +33,7 @@ interface FormTypeExtensionInterface
|
||||
* This method is called after the extended type has built the form to
|
||||
* further modify it.
|
||||
*
|
||||
* @param FormBuilderInterface<T> $builder
|
||||
* @param array<string, mixed> $options
|
||||
* @param array<string, mixed> $options
|
||||
*
|
||||
* @see FormTypeInterface::buildForm()
|
||||
*/
|
||||
@@ -48,8 +45,6 @@ interface FormTypeExtensionInterface
|
||||
* This method is called after the extended type has built the view to
|
||||
* further modify it.
|
||||
*
|
||||
* @param FormView<T> $view
|
||||
* @param FormInterface<T> $form
|
||||
* @param array<string, mixed> $options
|
||||
*
|
||||
* @see FormTypeInterface::buildView()
|
||||
@@ -62,8 +57,6 @@ interface FormTypeExtensionInterface
|
||||
* This method is called after the extended type has finished the view to
|
||||
* further modify it.
|
||||
*
|
||||
* @param FormView<T> $view
|
||||
* @param FormInterface<T> $form
|
||||
* @param array<string, mixed> $options
|
||||
*
|
||||
* @see FormTypeInterface::finishView()
|
||||
|
||||
@@ -15,8 +15,6 @@ use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||
|
||||
/**
|
||||
* @author Bernhard Schussek <bschussek@gmail.com>
|
||||
*
|
||||
* @template T
|
||||
*/
|
||||
interface FormTypeInterface
|
||||
{
|
||||
@@ -39,8 +37,7 @@ interface FormTypeInterface
|
||||
* This method is called for each type in the hierarchy starting from the
|
||||
* top most type. Type extensions can further modify the form.
|
||||
*
|
||||
* @param FormBuilderInterface<T> $builder
|
||||
* @param array<string, mixed> $options
|
||||
* @param array<string, mixed> $options
|
||||
*
|
||||
* @see FormTypeExtensionInterface::buildForm()
|
||||
*/
|
||||
@@ -56,9 +53,7 @@ interface FormTypeInterface
|
||||
* This means that you cannot access child views in this method. If you need
|
||||
* to do so, move your logic to {@link finishView()} instead.
|
||||
*
|
||||
* @param FormView<T> $form
|
||||
* @param FormInterface<T> $view
|
||||
* @param array<string, mixed> $options
|
||||
* @param array<string, mixed> $options
|
||||
*
|
||||
* @see FormTypeExtensionInterface::buildView()
|
||||
*/
|
||||
@@ -75,9 +70,7 @@ interface FormTypeInterface
|
||||
* such logic in this method that actually accesses child views. For everything
|
||||
* else you are recommended to implement {@link buildView()} instead.
|
||||
*
|
||||
* @param FormView<T> $form
|
||||
* @param FormInterface<T> $view
|
||||
* @param array<string, mixed> $options
|
||||
* @param array<string, mixed> $options
|
||||
*
|
||||
* @see FormTypeExtensionInterface::finishView()
|
||||
*/
|
||||
|
||||
@@ -16,8 +16,6 @@ use Symfony\Component\Form\Exception\BadMethodCallException;
|
||||
/**
|
||||
* @author Bernhard Schussek <bschussek@gmail.com>
|
||||
*
|
||||
* @template T
|
||||
*
|
||||
* @implements \ArrayAccess<int|string, FormView>
|
||||
* @implements \IteratorAggregate<int|string, FormView>
|
||||
*/
|
||||
@@ -25,8 +23,6 @@ class FormView implements \ArrayAccess, \IteratorAggregate, \Countable
|
||||
{
|
||||
/**
|
||||
* The variables assigned to this view.
|
||||
*
|
||||
* @var array{value: T|null, attr: array<array-key, mixed>, ...<string, mixed>}
|
||||
*/
|
||||
public array $vars = [
|
||||
'value' => null,
|
||||
|
||||
Reference in New Issue
Block a user