[Components] Convert to native return types

This commit is contained in:
Wouter de Jong
2023-07-02 23:52:21 +02:00
committed by Nicolas Grekas
parent 7f036f9525
commit 8266c81fce
92 changed files with 214 additions and 773 deletions

View File

@@ -98,7 +98,7 @@ abstract class AbstractExtension implements FormExtensionInterface
*
* @return FormTypeInterface[]
*/
protected function loadTypes()
protected function loadTypes(): array
{
return [];
}
@@ -115,10 +115,8 @@ abstract class AbstractExtension implements FormExtensionInterface
/**
* Registers the type guesser.
*
* @return FormTypeGuesserInterface|null
*/
protected function loadTypeGuesser()
protected function loadTypeGuesser(): ?FormTypeGuesserInterface
{
return null;
}

View File

@@ -61,10 +61,7 @@ abstract class AbstractRendererEngine implements FormRendererEngineInterface, Re
$this->defaultThemes = $defaultThemes;
}
/**
* @return void
*/
public function setTheme(FormView $view, mixed $themes, bool $useDefaultThemes = true)
public function setTheme(FormView $view, mixed $themes, bool $useDefaultThemes = true): void
{
$cacheKey = $view->vars[self::CACHE_KEY_VAR];
@@ -124,10 +121,8 @@ abstract class AbstractRendererEngine implements FormRendererEngineInterface, Re
* Loads the cache with the resource for a given block name.
*
* @see getResourceForBlock()
*
* @return bool
*/
abstract protected function loadResourceForBlockName(string $cacheKey, FormView $view, string $blockName);
abstract protected function loadResourceForBlockName(string $cacheKey, FormView $view, string $blockName): bool;
/**
* Loads the cache with the resource for a specific level of a block hierarchy.

View File

@@ -20,46 +20,28 @@ use Symfony\Component\OptionsResolver\OptionsResolver;
*/
abstract class AbstractType implements FormTypeInterface
{
/**
* @return void
*/
public function buildForm(FormBuilderInterface $builder, array $options)
public function buildForm(FormBuilderInterface $builder, array $options): void
{
}
/**
* @return void
*/
public function buildView(FormView $view, FormInterface $form, array $options)
public function buildView(FormView $view, FormInterface $form, array $options): void
{
}
/**
* @return void
*/
public function finishView(FormView $view, FormInterface $form, array $options)
public function finishView(FormView $view, FormInterface $form, array $options): void
{
}
/**
* @return void
*/
public function configureOptions(OptionsResolver $resolver)
public function configureOptions(OptionsResolver $resolver): void
{
}
/**
* @return string
*/
public function getBlockPrefix()
public function getBlockPrefix(): string
{
return StringUtil::fqcnToBlockPrefix(static::class) ?: '';
}
/**
* @return string|null
*/
public function getParent()
public function getParent(): ?string
{
return FormType::class;
}

View File

@@ -18,31 +18,19 @@ use Symfony\Component\OptionsResolver\OptionsResolver;
*/
abstract class AbstractTypeExtension implements FormTypeExtensionInterface
{
/**
* @return void
*/
public function buildForm(FormBuilderInterface $builder, array $options)
public function buildForm(FormBuilderInterface $builder, array $options): void
{
}
/**
* @return void
*/
public function buildView(FormView $view, FormInterface $form, array $options)
public function buildView(FormView $view, FormInterface $form, array $options): void
{
}
/**
* @return void
*/
public function finishView(FormView $view, FormInterface $form, array $options)
public function finishView(FormView $view, FormInterface $form, array $options): void
{
}
/**
* @return void
*/
public function configureOptions(OptionsResolver $resolver)
public function configureOptions(OptionsResolver $resolver): void
{
}
}

View File

@@ -11,7 +11,6 @@
namespace Symfony\Component\Form;
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Symfony\Component\Form\Exception\BadMethodCallException;
use Symfony\Component\Form\Exception\InvalidArgumentException;
@@ -52,11 +51,9 @@ class ButtonBuilder implements \IteratorAggregate, FormBuilderInterface
/**
* Unsupported method.
*
* @return never
*
* @throws BadMethodCallException
*/
public function add(string|FormBuilderInterface $child, string $type = null, array $options = []): static
public function add(string|FormBuilderInterface $child, string $type = null, array $options = []): never
{
throw new BadMethodCallException('Buttons cannot have children.');
}
@@ -64,11 +61,9 @@ class ButtonBuilder implements \IteratorAggregate, FormBuilderInterface
/**
* Unsupported method.
*
* @return never
*
* @throws BadMethodCallException
*/
public function create(string $name, string $type = null, array $options = []): FormBuilderInterface
public function create(string $name, string $type = null, array $options = []): never
{
throw new BadMethodCallException('Buttons cannot have children.');
}
@@ -76,11 +71,9 @@ class ButtonBuilder implements \IteratorAggregate, FormBuilderInterface
/**
* Unsupported method.
*
* @return never
*
* @throws BadMethodCallException
*/
public function get(string $name): FormBuilderInterface
public function get(string $name): never
{
throw new BadMethodCallException('Buttons cannot have children.');
}
@@ -88,11 +81,9 @@ class ButtonBuilder implements \IteratorAggregate, FormBuilderInterface
/**
* Unsupported method.
*
* @return never
*
* @throws BadMethodCallException
*/
public function remove(string $name): static
public function remove(string $name): never
{
throw new BadMethodCallException('Buttons cannot have children.');
}
@@ -124,11 +115,9 @@ class ButtonBuilder implements \IteratorAggregate, FormBuilderInterface
/**
* Unsupported method.
*
* @return never
*
* @throws BadMethodCallException
*/
public function addEventListener(string $eventName, callable $listener, int $priority = 0): static
public function addEventListener(string $eventName, callable $listener, int $priority = 0): never
{
throw new BadMethodCallException('Buttons do not support event listeners.');
}
@@ -136,11 +125,9 @@ class ButtonBuilder implements \IteratorAggregate, FormBuilderInterface
/**
* Unsupported method.
*
* @return never
*
* @throws BadMethodCallException
*/
public function addEventSubscriber(EventSubscriberInterface $subscriber): static
public function addEventSubscriber(EventSubscriberInterface $subscriber): never
{
throw new BadMethodCallException('Buttons do not support event subscribers.');
}
@@ -148,11 +135,9 @@ class ButtonBuilder implements \IteratorAggregate, FormBuilderInterface
/**
* Unsupported method.
*
* @return never
*
* @throws BadMethodCallException
*/
public function addViewTransformer(DataTransformerInterface $viewTransformer, bool $forcePrepend = false): static
public function addViewTransformer(DataTransformerInterface $viewTransformer, bool $forcePrepend = false): never
{
throw new BadMethodCallException('Buttons do not support data transformers.');
}
@@ -160,11 +145,9 @@ class ButtonBuilder implements \IteratorAggregate, FormBuilderInterface
/**
* Unsupported method.
*
* @return never
*
* @throws BadMethodCallException
*/
public function resetViewTransformers(): static
public function resetViewTransformers(): never
{
throw new BadMethodCallException('Buttons do not support data transformers.');
}
@@ -172,11 +155,9 @@ class ButtonBuilder implements \IteratorAggregate, FormBuilderInterface
/**
* Unsupported method.
*
* @return never
*
* @throws BadMethodCallException
*/
public function addModelTransformer(DataTransformerInterface $modelTransformer, bool $forceAppend = false): static
public function addModelTransformer(DataTransformerInterface $modelTransformer, bool $forceAppend = false): never
{
throw new BadMethodCallException('Buttons do not support data transformers.');
}
@@ -184,11 +165,9 @@ class ButtonBuilder implements \IteratorAggregate, FormBuilderInterface
/**
* Unsupported method.
*
* @return never
*
* @throws BadMethodCallException
*/
public function resetModelTransformers(): static
public function resetModelTransformers(): never
{
throw new BadMethodCallException('Buttons do not support data transformers.');
}
@@ -216,11 +195,9 @@ class ButtonBuilder implements \IteratorAggregate, FormBuilderInterface
/**
* Unsupported method.
*
* @return never
*
* @throws BadMethodCallException
*/
public function setDataMapper(?DataMapperInterface $dataMapper): static
public function setDataMapper(?DataMapperInterface $dataMapper): never
{
throw new BadMethodCallException('Buttons do not support data mappers.');
}
@@ -240,11 +217,9 @@ class ButtonBuilder implements \IteratorAggregate, FormBuilderInterface
/**
* Unsupported method.
*
* @return never
*
* @throws BadMethodCallException
*/
public function setEmptyData(mixed $emptyData): static
public function setEmptyData(mixed $emptyData): never
{
throw new BadMethodCallException('Buttons do not support empty data.');
}
@@ -252,11 +227,9 @@ class ButtonBuilder implements \IteratorAggregate, FormBuilderInterface
/**
* Unsupported method.
*
* @return never
*
* @throws BadMethodCallException
*/
public function setErrorBubbling(bool $errorBubbling): static
public function setErrorBubbling(bool $errorBubbling): never
{
throw new BadMethodCallException('Buttons do not support error bubbling.');
}
@@ -264,11 +237,9 @@ class ButtonBuilder implements \IteratorAggregate, FormBuilderInterface
/**
* Unsupported method.
*
* @return never
*
* @throws BadMethodCallException
*/
public function setRequired(bool $required): static
public function setRequired(bool $required): never
{
throw new BadMethodCallException('Buttons cannot be required.');
}
@@ -276,11 +247,9 @@ class ButtonBuilder implements \IteratorAggregate, FormBuilderInterface
/**
* Unsupported method.
*
* @return never
*
* @throws BadMethodCallException
*/
public function setPropertyPath(string|PropertyPathInterface|null $propertyPath): static
public function setPropertyPath(string|PropertyPathInterface|null $propertyPath): never
{
throw new BadMethodCallException('Buttons do not support property paths.');
}
@@ -288,11 +257,9 @@ class ButtonBuilder implements \IteratorAggregate, FormBuilderInterface
/**
* Unsupported method.
*
* @return never
*
* @throws BadMethodCallException
*/
public function setMapped(bool $mapped): static
public function setMapped(bool $mapped): never
{
throw new BadMethodCallException('Buttons do not support data mapping.');
}
@@ -300,11 +267,9 @@ class ButtonBuilder implements \IteratorAggregate, FormBuilderInterface
/**
* Unsupported method.
*
* @return never
*
* @throws BadMethodCallException
*/
public function setByReference(bool $byReference): static
public function setByReference(bool $byReference): never
{
throw new BadMethodCallException('Buttons do not support data mapping.');
}
@@ -312,11 +277,9 @@ class ButtonBuilder implements \IteratorAggregate, FormBuilderInterface
/**
* Unsupported method.
*
* @return never
*
* @throws BadMethodCallException
*/
public function setCompound(bool $compound): static
public function setCompound(bool $compound): never
{
throw new BadMethodCallException('Buttons cannot be compound.');
}
@@ -336,11 +299,9 @@ class ButtonBuilder implements \IteratorAggregate, FormBuilderInterface
/**
* Unsupported method.
*
* @return never
*
* @throws BadMethodCallException
*/
public function setData(mixed $data): static
public function setData(mixed $data): never
{
throw new BadMethodCallException('Buttons do not support data.');
}
@@ -348,11 +309,9 @@ class ButtonBuilder implements \IteratorAggregate, FormBuilderInterface
/**
* Unsupported method.
*
* @return never
*
* @throws BadMethodCallException
*/
public function setDataLocked(bool $locked): static
public function setDataLocked(bool $locked): never
{
throw new BadMethodCallException('Buttons do not support data locking.');
}
@@ -360,11 +319,9 @@ class ButtonBuilder implements \IteratorAggregate, FormBuilderInterface
/**
* Unsupported method.
*
* @return never
*
* @throws BadMethodCallException
*/
public function setFormFactory(FormFactoryInterface $formFactory)
public function setFormFactory(FormFactoryInterface $formFactory): never
{
throw new BadMethodCallException('Buttons do not support form factories.');
}
@@ -372,11 +329,9 @@ class ButtonBuilder implements \IteratorAggregate, FormBuilderInterface
/**
* Unsupported method.
*
* @return never
*
* @throws BadMethodCallException
*/
public function setAction(string $action): static
public function setAction(string $action): never
{
throw new BadMethodCallException('Buttons do not support actions.');
}
@@ -384,11 +339,9 @@ class ButtonBuilder implements \IteratorAggregate, FormBuilderInterface
/**
* Unsupported method.
*
* @return never
*
* @throws BadMethodCallException
*/
public function setMethod(string $method): static
public function setMethod(string $method): never
{
throw new BadMethodCallException('Buttons do not support methods.');
}
@@ -396,11 +349,9 @@ class ButtonBuilder implements \IteratorAggregate, FormBuilderInterface
/**
* Unsupported method.
*
* @return never
*
* @throws BadMethodCallException
*/
public function setRequestHandler(RequestHandlerInterface $requestHandler): static
public function setRequestHandler(RequestHandlerInterface $requestHandler): never
{
throw new BadMethodCallException('Buttons do not support request handlers.');
}
@@ -424,11 +375,9 @@ class ButtonBuilder implements \IteratorAggregate, FormBuilderInterface
/**
* Unsupported method.
*
* @return never
*
* @throws BadMethodCallException
*/
public function setInheritData(bool $inheritData): static
public function setInheritData(bool $inheritData): never
{
throw new BadMethodCallException('Buttons do not support data inheritance.');
}
@@ -448,11 +397,9 @@ class ButtonBuilder implements \IteratorAggregate, FormBuilderInterface
/**
* Unsupported method.
*
* @return never
*
* @throws BadMethodCallException
*/
public function setIsEmptyCallback(?callable $isEmptyCallback): static
public function setIsEmptyCallback(?callable $isEmptyCallback): never
{
throw new BadMethodCallException('Buttons do not support "is empty" callback.');
}
@@ -460,11 +407,9 @@ class ButtonBuilder implements \IteratorAggregate, FormBuilderInterface
/**
* Unsupported method.
*
* @return never
*
* @throws BadMethodCallException
*/
public function getEventDispatcher(): EventDispatcherInterface
public function getEventDispatcher(): never
{
throw new BadMethodCallException('Buttons do not support event dispatching.');
}
@@ -620,10 +565,8 @@ class ButtonBuilder implements \IteratorAggregate, FormBuilderInterface
/**
* Unsupported method.
*
* @return never
*/
public function getFormFactory(): FormFactoryInterface
public function getFormFactory(): never
{
throw new BadMethodCallException('Buttons do not support adding children.');
}
@@ -631,11 +574,9 @@ class ButtonBuilder implements \IteratorAggregate, FormBuilderInterface
/**
* Unsupported method.
*
* @return never
*
* @throws BadMethodCallException
*/
public function getAction(): string
public function getAction(): never
{
throw new BadMethodCallException('Buttons do not support actions.');
}
@@ -643,11 +584,9 @@ class ButtonBuilder implements \IteratorAggregate, FormBuilderInterface
/**
* Unsupported method.
*
* @return never
*
* @throws BadMethodCallException
*/
public function getMethod(): string
public function getMethod(): never
{
throw new BadMethodCallException('Buttons do not support methods.');
}
@@ -655,11 +594,9 @@ class ButtonBuilder implements \IteratorAggregate, FormBuilderInterface
/**
* Unsupported method.
*
* @return never
*
* @throws BadMethodCallException
*/
public function getRequestHandler(): RequestHandlerInterface
public function getRequestHandler(): never
{
throw new BadMethodCallException('Buttons do not support request handlers.');
}
@@ -707,11 +644,9 @@ class ButtonBuilder implements \IteratorAggregate, FormBuilderInterface
/**
* Unsupported method.
*
* @return never
*
* @throws BadMethodCallException
*/
public function getIsEmptyCallback(): ?callable
public function getIsEmptyCallback(): never
{
throw new BadMethodCallException('Buttons do not support "is empty" callback.');
}

View File

@@ -214,10 +214,7 @@ class CachingFactoryDecorator implements ChoiceListFactoryInterface, ResetInterf
return $this->views[$hash];
}
/**
* @return void
*/
public function reset()
public function reset(): void
{
$this->lists = [];
$this->views = [];

View File

@@ -54,10 +54,7 @@ class DebugCommand extends Command
$this->fileLinkFormatter = $fileLinkFormatter;
}
/**
* @return void
*/
protected function configure()
protected function configure(): void
{
$this
->setDefinition([

View File

@@ -25,11 +25,9 @@ interface DataMapperInterface
* @param mixed $viewData View data of the compound form being initialized
* @param \Traversable<mixed, FormInterface> $forms A list of {@link FormInterface} instances
*
* @return void
*
* @throws Exception\UnexpectedTypeException if the type of the data parameter is not supported
*/
public function mapDataToForms(mixed $viewData, \Traversable $forms);
public function mapDataToForms(mixed $viewData, \Traversable $forms): void;
/**
* Maps the model data of a list of children forms into the view data of their parent.
@@ -58,9 +56,7 @@ interface DataMapperInterface
* @param mixed &$viewData The compound form's view data that get mapped
* its children model data
*
* @return void
*
* @throws Exception\UnexpectedTypeException if the type of the data parameter is not supported
*/
public function mapFormsToData(\Traversable $forms, mixed &$viewData);
public function mapFormsToData(\Traversable $forms, mixed &$viewData): void;
}

View File

@@ -30,10 +30,7 @@ class FormPass implements CompilerPassInterface
{
use PriorityTaggedServiceTrait;
/**
* @return void
*/
public function process(ContainerBuilder $container)
public function process(ContainerBuilder $container): void
{
if (!$container->hasDefinition('form.extension')) {
return;

View File

@@ -25,10 +25,7 @@ use Symfony\Component\Form\Exception\UnexpectedTypeException;
*/
class CheckboxListMapper implements DataMapperInterface
{
/**
* @return void
*/
public function mapDataToForms(mixed $choices, \Traversable $checkboxes)
public function mapDataToForms(mixed $choices, \Traversable $checkboxes): void
{
if (!\is_array($choices ??= [])) {
throw new UnexpectedTypeException($choices, 'array');
@@ -40,10 +37,7 @@ class CheckboxListMapper implements DataMapperInterface
}
}
/**
* @return void
*/
public function mapFormsToData(\Traversable $checkboxes, mixed &$choices)
public function mapFormsToData(\Traversable $checkboxes, mixed &$choices): void
{
if (!\is_array($choices)) {
throw new UnexpectedTypeException($choices, 'array');

View File

@@ -25,10 +25,7 @@ use Symfony\Component\Form\Exception\UnexpectedTypeException;
*/
class RadioListMapper implements DataMapperInterface
{
/**
* @return void
*/
public function mapDataToForms(mixed $choice, \Traversable $radios)
public function mapDataToForms(mixed $choice, \Traversable $radios): void
{
if (!\is_string($choice)) {
throw new UnexpectedTypeException($choice, 'string');
@@ -40,10 +37,7 @@ class RadioListMapper implements DataMapperInterface
}
}
/**
* @return void
*/
public function mapFormsToData(\Traversable $radios, mixed &$choice)
public function mapFormsToData(\Traversable $radios, mixed &$choice): void
{
if (null !== $choice && !\is_string($choice)) {
throw new UnexpectedTypeException($choice, 'null or string');

View File

@@ -32,10 +32,7 @@ class FixUrlProtocolListener implements EventSubscriberInterface
$this->defaultProtocol = $defaultProtocol;
}
/**
* @return void
*/
public function onSubmit(FormEvent $event)
public function onSubmit(FormEvent $event): void
{
$data = $event->getData();

View File

@@ -41,10 +41,7 @@ class MergeCollectionListener implements EventSubscriberInterface
];
}
/**
* @return void
*/
public function onSubmit(FormEvent $event)
public function onSubmit(FormEvent $event): void
{
$dataToMergeInto = $event->getForm()->getNormData();
$data = $event->getData() ?? [];

View File

@@ -52,10 +52,7 @@ class ResizeFormListener implements EventSubscriberInterface
];
}
/**
* @return void
*/
public function preSetData(FormEvent $event)
public function preSetData(FormEvent $event): void
{
$form = $event->getForm();
$data = $event->getData() ?? [];
@@ -77,10 +74,7 @@ class ResizeFormListener implements EventSubscriberInterface
}
}
/**
* @return void
*/
public function preSubmit(FormEvent $event)
public function preSubmit(FormEvent $event): void
{
$form = $event->getForm();
$data = $event->getData();
@@ -110,10 +104,7 @@ class ResizeFormListener implements EventSubscriberInterface
}
}
/**
* @return void
*/
public function onSubmit(FormEvent $event)
public function onSubmit(FormEvent $event): void
{
$form = $event->getForm();
$data = $event->getData() ?? [];

View File

@@ -36,10 +36,7 @@ class TransformationFailureListener implements EventSubscriberInterface
];
}
/**
* @return void
*/
public function convertTransformationFailureToFormError(FormEvent $event)
public function convertTransformationFailureToFormError(FormEvent $event): void
{
$form = $event->getForm();

View File

@@ -23,10 +23,7 @@ use Symfony\Component\Form\Util\StringUtil;
*/
class TrimListener implements EventSubscriberInterface
{
/**
* @return void
*/
public function preSubmit(FormEvent $event)
public function preSubmit(FormEvent $event): void
{
$data = $event->getData();

View File

@@ -29,19 +29,13 @@ use Symfony\Component\OptionsResolver\OptionsResolver;
*/
abstract class BaseType extends AbstractType
{
/**
* @return void
*/
public function buildForm(FormBuilderInterface $builder, array $options)
public function buildForm(FormBuilderInterface $builder, array $options): void
{
$builder->setDisabled($options['disabled']);
$builder->setAutoInitialize($options['auto_initialize']);
}
/**
* @return void
*/
public function buildView(FormView $view, FormInterface $form, array $options)
public function buildView(FormView $view, FormInterface $form, array $options): void
{
$name = $form->getName();
$blockName = $options['block_name'] ?: $form->getName();
@@ -125,10 +119,7 @@ abstract class BaseType extends AbstractType
]);
}
/**
* @return void
*/
public function configureOptions(OptionsResolver $resolver)
public function configureOptions(OptionsResolver $resolver): void
{
$resolver->setDefaults([
'block_name' => null,

View File

@@ -16,10 +16,7 @@ use Symfony\Component\OptionsResolver\OptionsResolver;
class BirthdayType extends AbstractType
{
/**
* @return void
*/
public function configureOptions(OptionsResolver $resolver)
public function configureOptions(OptionsResolver $resolver): void
{
$resolver->setDefaults([
'years' => range((int) date('Y') - 120, date('Y')),

View File

@@ -31,10 +31,7 @@ class ButtonType extends BaseType implements ButtonTypeInterface
return 'button';
}
/**
* @return void
*/
public function configureOptions(OptionsResolver $resolver)
public function configureOptions(OptionsResolver $resolver): void
{
parent::configureOptions($resolver);

View File

@@ -20,10 +20,7 @@ use Symfony\Component\OptionsResolver\OptionsResolver;
class CheckboxType extends AbstractType
{
/**
* @return void
*/
public function buildForm(FormBuilderInterface $builder, array $options)
public function buildForm(FormBuilderInterface $builder, array $options): void
{
// Unlike in other types, where the data is NULL by default, it
// needs to be a Boolean here. setData(null) is not acceptable
@@ -35,10 +32,7 @@ class CheckboxType extends AbstractType
$builder->addViewTransformer(new BooleanToStringTransformer($options['value'], $options['false_values']));
}
/**
* @return void
*/
public function buildView(FormView $view, FormInterface $form, array $options)
public function buildView(FormView $view, FormInterface $form, array $options): void
{
$view->vars = array_replace($view->vars, [
'value' => $options['value'],
@@ -46,10 +40,7 @@ class CheckboxType extends AbstractType
]);
}
/**
* @return void
*/
public function configureOptions(OptionsResolver $resolver)
public function configureOptions(OptionsResolver $resolver): void
{
$emptyData = static fn (FormInterface $form, $viewData) => $viewData;

View File

@@ -62,10 +62,7 @@ class ChoiceType extends AbstractType
$this->translator = $translator;
}
/**
* @return void
*/
public function buildForm(FormBuilderInterface $builder, array $options)
public function buildForm(FormBuilderInterface $builder, array $options): void
{
$unknownValues = [];
$choiceList = $this->createChoiceList($options);
@@ -218,10 +215,7 @@ class ChoiceType extends AbstractType
}, 256);
}
/**
* @return void
*/
public function buildView(FormView $view, FormInterface $form, array $options)
public function buildView(FormView $view, FormInterface $form, array $options): void
{
$choiceTranslationDomain = $options['choice_translation_domain'];
if ($view->parent && null === $choiceTranslationDomain) {
@@ -275,10 +269,7 @@ class ChoiceType extends AbstractType
}
}
/**
* @return void
*/
public function finishView(FormView $view, FormInterface $form, array $options)
public function finishView(FormView $view, FormInterface $form, array $options): void
{
if ($options['expanded']) {
// Radio buttons should have the same name as the parent
@@ -295,10 +286,7 @@ class ChoiceType extends AbstractType
}
}
/**
* @return void
*/
public function configureOptions(OptionsResolver $resolver)
public function configureOptions(OptionsResolver $resolver): void
{
$emptyData = static function (Options $options) {
if ($options['expanded'] && !$options['multiple']) {

View File

@@ -21,10 +21,7 @@ use Symfony\Component\OptionsResolver\OptionsResolver;
class CollectionType extends AbstractType
{
/**
* @return void
*/
public function buildForm(FormBuilderInterface $builder, array $options)
public function buildForm(FormBuilderInterface $builder, array $options): void
{
$resizePrototypeOptions = null;
if ($options['allow_add'] && $options['prototype']) {
@@ -54,10 +51,7 @@ class CollectionType extends AbstractType
$builder->addEventSubscriber($resizeListener);
}
/**
* @return void
*/
public function buildView(FormView $view, FormInterface $form, array $options)
public function buildView(FormView $view, FormInterface $form, array $options): void
{
$view->vars = array_replace($view->vars, [
'allow_add' => $options['allow_add'],
@@ -70,10 +64,7 @@ class CollectionType extends AbstractType
}
}
/**
* @return void
*/
public function finishView(FormView $view, FormInterface $form, array $options)
public function finishView(FormView $view, FormInterface $form, array $options): void
{
$prefixOffset = -2;
// check if the entry type also defines a block prefix
@@ -104,10 +95,7 @@ class CollectionType extends AbstractType
}
}
/**
* @return void
*/
public function configureOptions(OptionsResolver $resolver)
public function configureOptions(OptionsResolver $resolver): void
{
$entryOptionsNormalizer = static function (Options $options, $value) {
$value['block_name'] = 'entry';

View File

@@ -33,10 +33,7 @@ class ColorType extends AbstractType
$this->translator = $translator;
}
/**
* @return void
*/
public function buildForm(FormBuilderInterface $builder, array $options)
public function buildForm(FormBuilderInterface $builder, array $options): void
{
if (!$options['html5']) {
return;
@@ -63,10 +60,7 @@ class ColorType extends AbstractType
});
}
/**
* @return void
*/
public function configureOptions(OptionsResolver $resolver)
public function configureOptions(OptionsResolver $resolver): void
{
$resolver->setDefaults([
'html5' => false,

View File

@@ -22,10 +22,7 @@ use Symfony\Component\OptionsResolver\OptionsResolver;
class CountryType extends AbstractType
{
/**
* @return void
*/
public function configureOptions(OptionsResolver $resolver)
public function configureOptions(OptionsResolver $resolver): void
{
$resolver->setDefaults([
'choice_loader' => function (Options $options) {

View File

@@ -22,10 +22,7 @@ use Symfony\Component\OptionsResolver\OptionsResolver;
class CurrencyType extends AbstractType
{
/**
* @return void
*/
public function configureOptions(OptionsResolver $resolver)
public function configureOptions(OptionsResolver $resolver): void
{
$resolver->setDefaults([
'choice_loader' => function (Options $options) {

View File

@@ -43,10 +43,7 @@ class DateIntervalType extends AbstractType
'choice' => ChoiceType::class,
];
/**
* @return void
*/
public function buildForm(FormBuilderInterface $builder, array $options)
public function buildForm(FormBuilderInterface $builder, array $options): void
{
if (!$options['with_years'] && !$options['with_months'] && !$options['with_weeks'] && !$options['with_days'] && !$options['with_hours'] && !$options['with_minutes'] && !$options['with_seconds']) {
throw new InvalidConfigurationException('You must enable at least one interval field.');
@@ -148,10 +145,7 @@ class DateIntervalType extends AbstractType
}
}
/**
* @return void
*/
public function buildView(FormView $view, FormInterface $form, array $options)
public function buildView(FormView $view, FormInterface $form, array $options): void
{
$vars = [
'widget' => $options['widget'],
@@ -163,10 +157,7 @@ class DateIntervalType extends AbstractType
$view->vars = array_replace($view->vars, $vars);
}
/**
* @return void
*/
public function configureOptions(OptionsResolver $resolver)
public function configureOptions(OptionsResolver $resolver): void
{
$compound = static fn (Options $options) => 'single_text' !== $options['widget'];
$emptyData = static fn (Options $options) => 'single_text' === $options['widget'] ? '' : [];

View File

@@ -49,10 +49,7 @@ class DateTimeType extends AbstractType
\IntlDateFormatter::SHORT,
];
/**
* @return void
*/
public function buildForm(FormBuilderInterface $builder, array $options)
public function buildForm(FormBuilderInterface $builder, array $options): void
{
$parts = ['year', 'month', 'day', 'hour'];
$dateParts = ['year', 'month', 'day'];
@@ -212,10 +209,7 @@ class DateTimeType extends AbstractType
}
}
/**
* @return void
*/
public function buildView(FormView $view, FormInterface $form, array $options)
public function buildView(FormView $view, FormInterface $form, array $options): void
{
$view->vars['widget'] = $options['widget'];
@@ -240,10 +234,7 @@ class DateTimeType extends AbstractType
}
}
/**
* @return void
*/
public function configureOptions(OptionsResolver $resolver)
public function configureOptions(OptionsResolver $resolver): void
{
$compound = static fn (Options $options) => 'single_text' !== $options['widget'];

View File

@@ -45,10 +45,7 @@ class DateType extends AbstractType
'choice' => ChoiceType::class,
];
/**
* @return void
*/
public function buildForm(FormBuilderInterface $builder, array $options)
public function buildForm(FormBuilderInterface $builder, array $options): void
{
$dateFormat = \is_int($options['format']) ? $options['format'] : self::DEFAULT_FORMAT;
$timeFormat = \IntlDateFormatter::NONE;
@@ -196,10 +193,7 @@ class DateType extends AbstractType
}
}
/**
* @return void
*/
public function finishView(FormView $view, FormInterface $form, array $options)
public function finishView(FormView $view, FormInterface $form, array $options): void
{
$view->vars['widget'] = $options['widget'];
@@ -236,10 +230,7 @@ class DateType extends AbstractType
}
}
/**
* @return void
*/
public function configureOptions(OptionsResolver $resolver)
public function configureOptions(OptionsResolver $resolver): void
{
$compound = static fn (Options $options) => 'single_text' !== $options['widget'];

View File

@@ -16,10 +16,7 @@ use Symfony\Component\OptionsResolver\OptionsResolver;
class EmailType extends AbstractType
{
/**
* @return void
*/
public function configureOptions(OptionsResolver $resolver)
public function configureOptions(OptionsResolver $resolver): void
{
$resolver->setDefaults([
'invalid_message' => 'Please enter a valid email address.',

View File

@@ -41,10 +41,7 @@ class FileType extends AbstractType
$this->translator = $translator;
}
/**
* @return void
*/
public function buildForm(FormBuilderInterface $builder, array $options)
public function buildForm(FormBuilderInterface $builder, array $options): void
{
// Ensure that submitted data is always an uploaded file or an array of some
$builder->addEventListener(FormEvents::PRE_SUBMIT, function (FormEvent $event) use ($options) {
@@ -85,10 +82,7 @@ class FileType extends AbstractType
});
}
/**
* @return void
*/
public function buildView(FormView $view, FormInterface $form, array $options)
public function buildView(FormView $view, FormInterface $form, array $options): void
{
if ($options['multiple']) {
$view->vars['full_name'] .= '[]';
@@ -101,18 +95,12 @@ class FileType extends AbstractType
]);
}
/**
* @return void
*/
public function finishView(FormView $view, FormInterface $form, array $options)
public function finishView(FormView $view, FormInterface $form, array $options): void
{
$view->vars['multipart'] = true;
}
/**
* @return void
*/
public function configureOptions(OptionsResolver $resolver)
public function configureOptions(OptionsResolver $resolver): void
{
$dataClass = null;
if (class_exists(File::class)) {

View File

@@ -38,10 +38,7 @@ class FormType extends BaseType
]));
}
/**
* @return void
*/
public function buildForm(FormBuilderInterface $builder, array $options)
public function buildForm(FormBuilderInterface $builder, array $options): void
{
parent::buildForm($builder, $options);
@@ -69,10 +66,7 @@ class FormType extends BaseType
$builder->setIsEmptyCallback($options['is_empty_callback']);
}
/**
* @return void
*/
public function buildView(FormView $view, FormInterface $form, array $options)
public function buildView(FormView $view, FormInterface $form, array $options): void
{
parent::buildView($view, $form, $options);
@@ -111,10 +105,7 @@ class FormType extends BaseType
]);
}
/**
* @return void
*/
public function finishView(FormView $view, FormInterface $form, array $options)
public function finishView(FormView $view, FormInterface $form, array $options): void
{
$multipart = false;
@@ -128,10 +119,7 @@ class FormType extends BaseType
$view->vars['multipart'] = $multipart;
}
/**
* @return void
*/
public function configureOptions(OptionsResolver $resolver)
public function configureOptions(OptionsResolver $resolver): void
{
parent::configureOptions($resolver);

View File

@@ -16,10 +16,7 @@ use Symfony\Component\OptionsResolver\OptionsResolver;
class HiddenType extends AbstractType
{
/**
* @return void
*/
public function configureOptions(OptionsResolver $resolver)
public function configureOptions(OptionsResolver $resolver): void
{
$resolver->setDefaults([
// hidden fields cannot have a required attribute

View File

@@ -20,28 +20,19 @@ use Symfony\Component\OptionsResolver\OptionsResolver;
class IntegerType extends AbstractType
{
/**
* @return void
*/
public function buildForm(FormBuilderInterface $builder, array $options)
public function buildForm(FormBuilderInterface $builder, array $options): void
{
$builder->addViewTransformer(new IntegerToLocalizedStringTransformer($options['grouping'], $options['rounding_mode'], !$options['grouping'] ? 'en' : null));
}
/**
* @return void
*/
public function buildView(FormView $view, FormInterface $form, array $options)
public function buildView(FormView $view, FormInterface $form, array $options): void
{
if ($options['grouping']) {
$view->vars['type'] = 'text';
}
}
/**
* @return void
*/
public function configureOptions(OptionsResolver $resolver)
public function configureOptions(OptionsResolver $resolver): void
{
$resolver->setDefaults([
'grouping' => false,

View File

@@ -23,10 +23,7 @@ use Symfony\Component\OptionsResolver\OptionsResolver;
class LanguageType extends AbstractType
{
/**
* @return void
*/
public function configureOptions(OptionsResolver $resolver)
public function configureOptions(OptionsResolver $resolver): void
{
$resolver->setDefaults([
'choice_loader' => function (Options $options) {

View File

@@ -22,10 +22,7 @@ use Symfony\Component\OptionsResolver\OptionsResolver;
class LocaleType extends AbstractType
{
/**
* @return void
*/
public function configureOptions(OptionsResolver $resolver)
public function configureOptions(OptionsResolver $resolver): void
{
$resolver->setDefaults([
'choice_loader' => function (Options $options) {

View File

@@ -24,10 +24,7 @@ class MoneyType extends AbstractType
{
protected static $patterns = [];
/**
* @return void
*/
public function buildForm(FormBuilderInterface $builder, array $options)
public function buildForm(FormBuilderInterface $builder, array $options): void
{
// Values used in HTML5 number inputs should be formatted as in "1234.5", ie. 'en' format without grouping,
// according to https://www.w3.org/TR/html51/sec-forms.html#date-time-and-number-formats
@@ -42,10 +39,7 @@ class MoneyType extends AbstractType
;
}
/**
* @return void
*/
public function buildView(FormView $view, FormInterface $form, array $options)
public function buildView(FormView $view, FormInterface $form, array $options): void
{
$view->vars['money_pattern'] = self::getPattern($options['currency']);
@@ -54,10 +48,7 @@ class MoneyType extends AbstractType
}
}
/**
* @return void
*/
public function configureOptions(OptionsResolver $resolver)
public function configureOptions(OptionsResolver $resolver): void
{
$resolver->setDefaults([
'scale' => 2,
@@ -103,10 +94,8 @@ class MoneyType extends AbstractType
*
* The pattern contains the placeholder "{{ widget }}" where the HTML tag should
* be inserted
*
* @return string
*/
protected static function getPattern(?string $currency)
protected static function getPattern(?string $currency): string
{
if (!$currency) {
return '{{ widget }}';

View File

@@ -23,10 +23,7 @@ use Symfony\Component\OptionsResolver\OptionsResolver;
class NumberType extends AbstractType
{
/**
* @return void
*/
public function buildForm(FormBuilderInterface $builder, array $options)
public function buildForm(FormBuilderInterface $builder, array $options): void
{
$builder->addViewTransformer(new NumberToLocalizedStringTransformer(
$options['scale'],
@@ -40,10 +37,7 @@ class NumberType extends AbstractType
}
}
/**
* @return void
*/
public function buildView(FormView $view, FormInterface $form, array $options)
public function buildView(FormView $view, FormInterface $form, array $options): void
{
if ($options['html5']) {
$view->vars['type'] = 'number';
@@ -56,10 +50,7 @@ class NumberType extends AbstractType
}
}
/**
* @return void
*/
public function configureOptions(OptionsResolver $resolver)
public function configureOptions(OptionsResolver $resolver): void
{
$resolver->setDefaults([
// default scale is locale specific (usually around 3)

View File

@@ -18,20 +18,14 @@ use Symfony\Component\OptionsResolver\OptionsResolver;
class PasswordType extends AbstractType
{
/**
* @return void
*/
public function buildView(FormView $view, FormInterface $form, array $options)
public function buildView(FormView $view, FormInterface $form, array $options): void
{
if ($options['always_empty'] || !$form->isSubmitted()) {
$view->vars['value'] = '';
}
}
/**
* @return void
*/
public function configureOptions(OptionsResolver $resolver)
public function configureOptions(OptionsResolver $resolver): void
{
$resolver->setDefaults([
'always_empty' => true,

View File

@@ -20,10 +20,7 @@ use Symfony\Component\OptionsResolver\OptionsResolver;
class PercentType extends AbstractType
{
/**
* @return void
*/
public function buildForm(FormBuilderInterface $builder, array $options)
public function buildForm(FormBuilderInterface $builder, array $options): void
{
$builder->addViewTransformer(new PercentToLocalizedStringTransformer(
$options['scale'],
@@ -33,10 +30,7 @@ class PercentType extends AbstractType
));
}
/**
* @return void
*/
public function buildView(FormView $view, FormInterface $form, array $options)
public function buildView(FormView $view, FormInterface $form, array $options): void
{
$view->vars['symbol'] = $options['symbol'];
@@ -45,10 +39,7 @@ class PercentType extends AbstractType
}
}
/**
* @return void
*/
public function configureOptions(OptionsResolver $resolver)
public function configureOptions(OptionsResolver $resolver): void
{
$resolver->setDefaults([
'scale' => 0,

View File

@@ -16,10 +16,7 @@ use Symfony\Component\OptionsResolver\OptionsResolver;
class RadioType extends AbstractType
{
/**
* @return void
*/
public function configureOptions(OptionsResolver $resolver)
public function configureOptions(OptionsResolver $resolver): void
{
$resolver->setDefaults([
'invalid_message' => 'Please select a valid option.',

View File

@@ -16,10 +16,7 @@ use Symfony\Component\OptionsResolver\OptionsResolver;
class RangeType extends AbstractType
{
/**
* @return void
*/
public function configureOptions(OptionsResolver $resolver)
public function configureOptions(OptionsResolver $resolver): void
{
$resolver->setDefaults([
'invalid_message' => 'Please choose a valid range.',

View File

@@ -18,10 +18,7 @@ use Symfony\Component\OptionsResolver\OptionsResolver;
class RepeatedType extends AbstractType
{
/**
* @return void
*/
public function buildForm(FormBuilderInterface $builder, array $options)
public function buildForm(FormBuilderInterface $builder, array $options): void
{
// Overwrite required option for child fields
$options['first_options']['required'] = $options['required'];
@@ -44,10 +41,7 @@ class RepeatedType extends AbstractType
;
}
/**
* @return void
*/
public function configureOptions(OptionsResolver $resolver)
public function configureOptions(OptionsResolver $resolver): void
{
$resolver->setDefaults([
'type' => TextType::class,

View File

@@ -16,10 +16,7 @@ use Symfony\Component\OptionsResolver\OptionsResolver;
class SearchType extends AbstractType
{
/**
* @return void
*/
public function configureOptions(OptionsResolver $resolver)
public function configureOptions(OptionsResolver $resolver): void
{
$resolver->setDefaults([
'invalid_message' => 'Please enter a valid search term.',

View File

@@ -24,10 +24,7 @@ use Symfony\Component\OptionsResolver\OptionsResolver;
*/
class SubmitType extends AbstractType implements SubmitButtonTypeInterface
{
/**
* @return void
*/
public function buildView(FormView $view, FormInterface $form, array $options)
public function buildView(FormView $view, FormInterface $form, array $options): void
{
$view->vars['clicked'] = $form->isClicked();
@@ -36,10 +33,7 @@ class SubmitType extends AbstractType implements SubmitButtonTypeInterface
}
}
/**
* @return void
*/
public function configureOptions(OptionsResolver $resolver)
public function configureOptions(OptionsResolver $resolver): void
{
$resolver->setDefault('validate', true);
$resolver->setAllowedTypes('validate', 'bool');

View File

@@ -16,10 +16,7 @@ use Symfony\Component\OptionsResolver\OptionsResolver;
class TelType extends AbstractType
{
/**
* @return void
*/
public function configureOptions(OptionsResolver $resolver)
public function configureOptions(OptionsResolver $resolver): void
{
$resolver->setDefaults([
'invalid_message' => 'Please provide a valid phone number.',

View File

@@ -18,10 +18,7 @@ use Symfony\Component\OptionsResolver\OptionsResolver;
class TextType extends AbstractType implements DataTransformerInterface
{
/**
* @return void
*/
public function buildForm(FormBuilderInterface $builder, array $options)
public function buildForm(FormBuilderInterface $builder, array $options): void
{
// When empty_data is explicitly set to an empty string,
// a string should always be returned when NULL is submitted
@@ -33,10 +30,7 @@ class TextType extends AbstractType implements DataTransformerInterface
}
}
/**
* @return void
*/
public function configureOptions(OptionsResolver $resolver)
public function configureOptions(OptionsResolver $resolver): void
{
$resolver->setDefaults([
'compound' => false,

View File

@@ -17,10 +17,7 @@ use Symfony\Component\Form\FormView;
class TextareaType extends AbstractType
{
/**
* @return void
*/
public function buildView(FormView $view, FormInterface $form, array $options)
public function buildView(FormView $view, FormInterface $form, array $options): void
{
$view->vars['pattern'] = null;
unset($view->vars['attr']['pattern']);

View File

@@ -34,10 +34,7 @@ class TimeType extends AbstractType
'choice' => ChoiceType::class,
];
/**
* @return void
*/
public function buildForm(FormBuilderInterface $builder, array $options)
public function buildForm(FormBuilderInterface $builder, array $options): void
{
$parts = ['hour'];
$format = 'H';
@@ -224,10 +221,7 @@ class TimeType extends AbstractType
}
}
/**
* @return void
*/
public function buildView(FormView $view, FormInterface $form, array $options)
public function buildView(FormView $view, FormInterface $form, array $options): void
{
$view->vars = array_replace($view->vars, [
'widget' => $options['widget'],
@@ -255,10 +249,7 @@ class TimeType extends AbstractType
}
}
/**
* @return void
*/
public function configureOptions(OptionsResolver $resolver)
public function configureOptions(OptionsResolver $resolver): void
{
$compound = static fn (Options $options) => 'single_text' !== $options['widget'];

View File

@@ -25,10 +25,7 @@ use Symfony\Component\OptionsResolver\OptionsResolver;
class TimezoneType extends AbstractType
{
/**
* @return void
*/
public function buildForm(FormBuilderInterface $builder, array $options)
public function buildForm(FormBuilderInterface $builder, array $options): void
{
if ('datetimezone' === $options['input']) {
$builder->addModelTransformer(new DateTimeZoneToStringTransformer($options['multiple']));
@@ -37,10 +34,7 @@ class TimezoneType extends AbstractType
}
}
/**
* @return void
*/
public function configureOptions(OptionsResolver $resolver)
public function configureOptions(OptionsResolver $resolver): void
{
$resolver->setDefaults([
'intl' => false,

View File

@@ -28,10 +28,7 @@ class TransformationFailureExtension extends AbstractTypeExtension
$this->translator = $translator;
}
/**
* @return void
*/
public function buildForm(FormBuilderInterface $builder, array $options)
public function buildForm(FormBuilderInterface $builder, array $options): void
{
if (!isset($options['constraints'])) {
$builder->addEventSubscriber(new TransformationFailureListener($this->translator));

View File

@@ -21,20 +21,14 @@ use Symfony\Component\OptionsResolver\OptionsResolver;
*/
class UlidType extends AbstractType
{
/**
* @return void
*/
public function buildForm(FormBuilderInterface $builder, array $options)
public function buildForm(FormBuilderInterface $builder, array $options): void
{
$builder
->addViewTransformer(new UlidToStringTransformer())
;
}
/**
* @return void
*/
public function configureOptions(OptionsResolver $resolver)
public function configureOptions(OptionsResolver $resolver): void
{
$resolver->setDefaults([
'compound' => false,

View File

@@ -20,20 +20,14 @@ use Symfony\Component\OptionsResolver\OptionsResolver;
class UrlType extends AbstractType
{
/**
* @return void
*/
public function buildForm(FormBuilderInterface $builder, array $options)
public function buildForm(FormBuilderInterface $builder, array $options): void
{
if (null !== $options['default_protocol']) {
$builder->addEventSubscriber(new FixUrlProtocolListener($options['default_protocol']));
}
}
/**
* @return void
*/
public function buildView(FormView $view, FormInterface $form, array $options)
public function buildView(FormView $view, FormInterface $form, array $options): void
{
if ($options['default_protocol']) {
$view->vars['attr']['inputmode'] = 'url';
@@ -41,10 +35,7 @@ class UrlType extends AbstractType
}
}
/**
* @return void
*/
public function configureOptions(OptionsResolver $resolver)
public function configureOptions(OptionsResolver $resolver): void
{
$resolver->setDefaults([
'default_protocol' => 'http',

View File

@@ -21,20 +21,14 @@ use Symfony\Component\OptionsResolver\OptionsResolver;
*/
class UuidType extends AbstractType
{
/**
* @return void
*/
public function buildForm(FormBuilderInterface $builder, array $options)
public function buildForm(FormBuilderInterface $builder, array $options): void
{
$builder
->addViewTransformer(new UuidToStringTransformer())
;
}
/**
* @return void
*/
public function configureOptions(OptionsResolver $resolver)
public function configureOptions(OptionsResolver $resolver): void
{
$resolver->setDefaults([
'compound' => false,

View File

@@ -28,10 +28,7 @@ class WeekType extends AbstractType
'choice' => ChoiceType::class,
];
/**
* @return void
*/
public function buildForm(FormBuilderInterface $builder, array $options)
public function buildForm(FormBuilderInterface $builder, array $options): void
{
if ('string' === $options['input']) {
$builder->addModelTransformer(new WeekToArrayTransformer());
@@ -83,10 +80,7 @@ class WeekType extends AbstractType
}
}
/**
* @return void
*/
public function buildView(FormView $view, FormInterface $form, array $options)
public function buildView(FormView $view, FormInterface $form, array $options): void
{
$view->vars['widget'] = $options['widget'];
@@ -95,10 +89,7 @@ class WeekType extends AbstractType
}
}
/**
* @return void
*/
public function configureOptions(OptionsResolver $resolver)
public function configureOptions(OptionsResolver $resolver): void
{
$compound = static fn (Options $options) => 'single_text' !== $options['widget'];

View File

@@ -51,10 +51,7 @@ class CsrfValidationListener implements EventSubscriberInterface
$this->serverParams = $serverParams ?? new ServerParams();
}
/**
* @return void
*/
public function preSubmit(FormEvent $event)
public function preSubmit(FormEvent $event): void
{
$form = $event->getForm();
$postRequestSizeExceeded = 'POST' === $form->getConfig()->getMethod() && $this->serverParams->hasPostMaxSizeBeenExceeded();

View File

@@ -47,10 +47,8 @@ class FormTypeCsrfExtension extends AbstractTypeExtension
/**
* Adds a CSRF field to the form when the CSRF protection is enabled.
*
* @return void
*/
public function buildForm(FormBuilderInterface $builder, array $options)
public function buildForm(FormBuilderInterface $builder, array $options): void
{
if (!$options['csrf_protection']) {
return;
@@ -71,10 +69,8 @@ class FormTypeCsrfExtension extends AbstractTypeExtension
/**
* Adds a CSRF field to the root form view.
*
* @return void
*/
public function finishView(FormView $view, FormInterface $form, array $options)
public function finishView(FormView $view, FormInterface $form, array $options): void
{
if ($options['csrf_protection'] && !$view->parent && $options['compound']) {
$factory = $form->getConfig()->getFormFactory();
@@ -90,10 +86,7 @@ class FormTypeCsrfExtension extends AbstractTypeExtension
}
}
/**
* @return void
*/
public function configureOptions(OptionsResolver $resolver)
public function configureOptions(OptionsResolver $resolver): void
{
$resolver->setDefaults([
'csrf_protection' => $this->defaultEnabled,

View File

@@ -43,10 +43,8 @@ class DataCollectorListener implements EventSubscriberInterface
/**
* Listener for the {@link FormEvents::POST_SET_DATA} event.
*
* @return void
*/
public function postSetData(FormEvent $event)
public function postSetData(FormEvent $event): void
{
if ($event->getForm()->isRoot()) {
// Collect basic information about each form
@@ -59,10 +57,8 @@ class DataCollectorListener implements EventSubscriberInterface
/**
* Listener for the {@link FormEvents::POST_SUBMIT} event.
*
* @return void
*/
public function postSubmit(FormEvent $event)
public function postSubmit(FormEvent $event): void
{
if ($event->getForm()->isRoot()) {
// Collect the submitted data of each form

View File

@@ -25,48 +25,36 @@ interface FormDataCollectorInterface extends DataCollectorInterface
{
/**
* Stores configuration data of the given form and its children.
*
* @return void
*/
public function collectConfiguration(FormInterface $form);
public function collectConfiguration(FormInterface $form): void;
/**
* Stores the default data of the given form and its children.
*
* @return void
*/
public function collectDefaultData(FormInterface $form);
public function collectDefaultData(FormInterface $form): void;
/**
* Stores the submitted data of the given form and its children.
*
* @return void
*/
public function collectSubmittedData(FormInterface $form);
public function collectSubmittedData(FormInterface $form): void;
/**
* Stores the view variables of the given form view and its children.
*
* @return void
*/
public function collectViewVariables(FormView $view);
public function collectViewVariables(FormView $view): void;
/**
* Specifies that the given objects represent the same conceptual form.
*
* @return void
*/
public function associateFormWithView(FormInterface $form, FormView $view);
public function associateFormWithView(FormInterface $form, FormView $view): void;
/**
* Assembles the data collected about the given form and its children as
* a tree-like data structure.
*
* The result can be queried using {@link getData()}.
*
* @return void
*/
public function buildPreliminaryFormTree(FormInterface $form);
public function buildPreliminaryFormTree(FormInterface $form): void;
/**
* Assembles the data collected about the given form and its children as
@@ -85,10 +73,8 @@ interface FormDataCollectorInterface extends DataCollectorInterface
* tree, only the view data will be included in the result. If a
* corresponding {@link FormInterface} exists otherwise, call
* {@link associateFormWithView()} before calling this method.
*
* @return void
*/
public function buildFinalFormTree(FormInterface $form, FormView $view);
public function buildFinalFormTree(FormInterface $form, FormView $view): void;
/**
* Returns all collected data.

View File

@@ -71,26 +71,17 @@ class ResolvedTypeDataCollectorProxy implements ResolvedFormTypeInterface
return $this->proxiedType->createView($form, $parent);
}
/**
* @return void
*/
public function buildForm(FormBuilderInterface $builder, array $options)
public function buildForm(FormBuilderInterface $builder, array $options): void
{
$this->proxiedType->buildForm($builder, $options);
}
/**
* @return void
*/
public function buildView(FormView $view, FormInterface $form, array $options)
public function buildView(FormView $view, FormInterface $form, array $options): void
{
$this->proxiedType->buildView($view, $form, $options);
}
/**
* @return void
*/
public function finishView(FormView $view, FormInterface $form, array $options)
public function finishView(FormView $view, FormInterface $form, array $options): void
{
$this->proxiedType->finishView($view, $form, $options);

View File

@@ -32,10 +32,7 @@ class DataCollectorTypeExtension extends AbstractTypeExtension
$this->listener = new DataCollectorListener($dataCollector);
}
/**
* @return void
*/
public function buildForm(FormBuilderInterface $builder, array $options)
public function buildForm(FormBuilderInterface $builder, array $options): void
{
$builder->addEventSubscriber($this->listener);
}

View File

@@ -35,10 +35,7 @@ class TextTypeHtmlSanitizerExtension extends AbstractTypeExtension
return [TextType::class];
}
/**
* @return void
*/
public function configureOptions(OptionsResolver $resolver)
public function configureOptions(OptionsResolver $resolver): void
{
$resolver
->setDefaults(['sanitize_html' => false, 'sanitizer' => null])
@@ -47,10 +44,7 @@ class TextTypeHtmlSanitizerExtension extends AbstractTypeExtension
;
}
/**
* @return void
*/
public function buildForm(FormBuilderInterface $builder, array $options)
public function buildForm(FormBuilderInterface $builder, array $options): void
{
if (!$options['sanitize_html']) {
return;

View File

@@ -35,10 +35,7 @@ class HttpFoundationRequestHandler implements RequestHandlerInterface
$this->serverParams = $serverParams ?? new ServerParams();
}
/**
* @return void
*/
public function handleRequest(FormInterface $form, mixed $request = null)
public function handleRequest(FormInterface $form, mixed $request = null): void
{
if (!$request instanceof Request) {
throw new UnexpectedTypeException($request, Request::class);

View File

@@ -29,10 +29,7 @@ class FormTypeHttpFoundationExtension extends AbstractTypeExtension
$this->requestHandler = $requestHandler ?? new HttpFoundationRequestHandler();
}
/**
* @return void
*/
public function buildForm(FormBuilderInterface $builder, array $options)
public function buildForm(FormBuilderInterface $builder, array $options): void
{
$builder->setRequestHandler($this->requestHandler);
}

View File

@@ -35,10 +35,7 @@ class PasswordHasherListener
$this->propertyAccessor ??= PropertyAccess::createPropertyAccessor();
}
/**
* @return void
*/
public function registerPassword(FormEvent $event)
public function registerPassword(FormEvent $event): void
{
if (null === $event->getData() || '' === $event->getData()) {
return;
@@ -53,10 +50,7 @@ class PasswordHasherListener
];
}
/**
* @return void
*/
public function hashPasswords(FormEvent $event)
public function hashPasswords(FormEvent $event): void
{
$form = $event->getForm();

View File

@@ -27,10 +27,7 @@ class FormTypePasswordHasherExtension extends AbstractTypeExtension
) {
}
/**
* @return void
*/
public function buildForm(FormBuilderInterface $builder, array $options)
public function buildForm(FormBuilderInterface $builder, array $options): void
{
$builder->addEventListener(FormEvents::POST_SUBMIT, [$this->passwordHasherListener, 'hashPasswords']);
}

View File

@@ -29,20 +29,14 @@ class PasswordTypePasswordHasherExtension extends AbstractTypeExtension
) {
}
/**
* @return void
*/
public function buildForm(FormBuilderInterface $builder, array $options)
public function buildForm(FormBuilderInterface $builder, array $options): void
{
if ($options['hash_property_path']) {
$builder->addEventListener(FormEvents::POST_SUBMIT, [$this->passwordHasherListener, 'registerPassword']);
}
}
/**
* @return void
*/
public function configureOptions(OptionsResolver $resolver)
public function configureOptions(OptionsResolver $resolver): void
{
$resolver->setDefaults([
'hash_property_path' => null,

View File

@@ -29,10 +29,7 @@ class FormValidator extends ConstraintValidator
*/
private \SplObjectStorage $resolvedGroups;
/**
* @return void
*/
public function validate(mixed $form, Constraint $formConstraint)
public function validate(mixed $form, Constraint $formConstraint): void
{
if (!$formConstraint instanceof Form) {
throw new UnexpectedTypeException($formConstraint, Form::class);

View File

@@ -37,10 +37,7 @@ class ValidationListener implements EventSubscriberInterface
$this->violationMapper = $violationMapper;
}
/**
* @return void
*/
public function validateForm(FormEvent $event)
public function validateForm(FormEvent $event): void
{
$form = $event->getForm();

View File

@@ -24,10 +24,7 @@ use Symfony\Component\Validator\Constraints\GroupSequence;
*/
abstract class BaseValidatorExtension extends AbstractTypeExtension
{
/**
* @return void
*/
public function configureOptions(OptionsResolver $resolver)
public function configureOptions(OptionsResolver $resolver): void
{
// Make sure that validation groups end up as null, closure or array
$validationGroupsNormalizer = static function (Options $options, $groups) {

View File

@@ -37,18 +37,12 @@ class FormTypeValidatorExtension extends BaseValidatorExtension
$this->violationMapper = new ViolationMapper($formRenderer, $translator);
}
/**
* @return void
*/
public function buildForm(FormBuilderInterface $builder, array $options)
public function buildForm(FormBuilderInterface $builder, array $options): void
{
$builder->addEventSubscriber(new ValidationListener($this->validator, $this->violationMapper));
}
/**
* @return void
*/
public function configureOptions(OptionsResolver $resolver)
public function configureOptions(OptionsResolver $resolver): void
{
parent::configureOptions($resolver);

View File

@@ -21,10 +21,7 @@ use Symfony\Component\OptionsResolver\OptionsResolver;
*/
class RepeatedTypeValidatorExtension extends AbstractTypeExtension
{
/**
* @return void
*/
public function configureOptions(OptionsResolver $resolver)
public function configureOptions(OptionsResolver $resolver): void
{
// Map errors to the first field
$errorMapping = static fn (Options $options) => ['.' => $options['first_name']];

View File

@@ -32,10 +32,7 @@ class UploadValidatorExtension extends AbstractTypeExtension
$this->translationDomain = $translationDomain;
}
/**
* @return void
*/
public function configureOptions(OptionsResolver $resolver)
public function configureOptions(OptionsResolver $resolver): void
{
$translator = $this->translator;
$translationDomain = $this->translationDomain;

View File

@@ -38,10 +38,7 @@ class ViolationMapper implements ViolationMapperInterface
$this->translator = $translator;
}
/**
* @return void
*/
public function mapViolation(ConstraintViolation $violation, FormInterface $form, bool $allowNonSynchronized = false)
public function mapViolation(ConstraintViolation $violation, FormInterface $form, bool $allowNonSynchronized = false): void
{
$this->allowNonSynchronized = $allowNonSynchronized;

View File

@@ -24,8 +24,6 @@ interface ViolationMapperInterface
* the given form.
*
* @param bool $allowNonSynchronized Whether to allow mapping to non-synchronized forms
*
* @return void
*/
public function mapViolation(ConstraintViolation $violation, FormInterface $form, bool $allowNonSynchronized = false);
public function mapViolation(ConstraintViolation $violation, FormInterface $form, bool $allowNonSynchronized = false): void;
}

View File

@@ -23,10 +23,7 @@ class ViolationPathIterator extends PropertyPathIterator
parent::__construct($violationPath);
}
/**
* @return bool
*/
public function mapsForm()
public function mapsForm(): bool
{
return $this->path->mapsForm($this->key());
}

View File

@@ -27,7 +27,7 @@ interface FormBuilderInterface extends \Traversable, \Countable, FormConfigBuild
*
* @param array<string, mixed> $options
*/
public function add(string|FormBuilderInterface $child, string $type = null, array $options = []): static;
public function add(string|self $child, string $type = null, array $options = []): static;
/**
* Creates a form builder.

View File

@@ -533,7 +533,7 @@ class FormConfigBuilder implements FormConfigBuilderInterface
/**
* @return $this
*/
public function setFormFactory(FormFactoryInterface $formFactory)
public function setFormFactory(FormFactoryInterface $formFactory): static
{
if ($this->locked) {
throw new BadMethodCallException('FormConfigBuilder methods cannot be accessed anymore once the builder is turned into a FormConfigInterface instance.');

View File

@@ -208,7 +208,7 @@ interface FormConfigBuilderInterface extends FormConfigInterface
*
* @return $this
*/
public function setFormFactory(FormFactoryInterface $formFactory);
public function setFormFactory(FormFactoryInterface $formFactory): static;
/**
* Sets the target URL of the form.

View File

@@ -99,11 +99,9 @@ class FormError
*
* This method must only be called once.
*
* @return void
*
* @throws BadMethodCallException If the method is called more than once
*/
public function setOrigin(FormInterface $origin)
public function setOrigin(FormInterface $origin): void
{
if (null !== $this->origin) {
throw new BadMethodCallException('setOrigin() must only be called once.');

View File

@@ -45,10 +45,8 @@ class FormEvent extends Event
/**
* Allows updating with some filtered data.
*
* @return void
*/
public function setData(mixed $data)
public function setData(mixed $data): void
{
$this->data = $data;
}

View File

@@ -42,10 +42,7 @@ class FormRenderer implements FormRendererInterface
return $this->engine;
}
/**
* @return void
*/
public function setTheme(FormView $view, mixed $themes, bool $useDefaultThemes = true)
public function setTheme(FormView $view, mixed $themes, bool $useDefaultThemes = true): void
{
$this->engine->setTheme($view, $themes, $useDefaultThemes);
}

View File

@@ -24,10 +24,8 @@ interface FormRendererEngineInterface
* @param FormView $view The view to assign the theme(s) to
* @param mixed $themes The theme(s). The type of these themes
* is open to the implementation.
*
* @return void
*/
public function setTheme(FormView $view, mixed $themes, bool $useDefaultThemes = true);
public function setTheme(FormView $view, mixed $themes, bool $useDefaultThemes = true): void;
/**
* Returns the resource for a block name.
@@ -129,8 +127,6 @@ interface FormRendererEngineInterface
* @param FormView $view The view to render
* @param mixed $resource The renderer resource
* @param array $variables The variables to pass to the template
*
* @return string
*/
public function renderBlock(FormView $view, mixed $resource, string $blockName, array $variables = []);
public function renderBlock(FormView $view, mixed $resource, string $blockName, array $variables = []): string;
}

View File

@@ -31,10 +31,8 @@ interface FormRendererInterface
* is open to the implementation.
* @param bool $useDefaultThemes If true, will use default themes specified
* in the renderer
*
* @return void
*/
public function setTheme(FormView $view, mixed $themes, bool $useDefaultThemes = true);
public function setTheme(FormView $view, mixed $themes, bool $useDefaultThemes = true): void;
/**
* Renders a named block of the form theme.

View File

@@ -26,11 +26,9 @@ interface FormTypeExtensionInterface
*
* @param array<string, mixed> $options
*
* @return void
*
* @see FormTypeInterface::buildForm()
*/
public function buildForm(FormBuilderInterface $builder, array $options);
public function buildForm(FormBuilderInterface $builder, array $options): void;
/**
* Builds the view.
@@ -40,11 +38,9 @@ interface FormTypeExtensionInterface
*
* @param array<string, mixed> $options
*
* @return void
*
* @see FormTypeInterface::buildView()
*/
public function buildView(FormView $view, FormInterface $form, array $options);
public function buildView(FormView $view, FormInterface $form, array $options): void;
/**
* Finishes the view.
@@ -54,16 +50,11 @@ interface FormTypeExtensionInterface
*
* @param array<string, mixed> $options
*
* @return void
*
* @see FormTypeInterface::finishView()
*/
public function finishView(FormView $view, FormInterface $form, array $options);
public function finishView(FormView $view, FormInterface $form, array $options): void;
/**
* @return void
*/
public function configureOptions(OptionsResolver $resolver);
public function configureOptions(OptionsResolver $resolver): void;
/**
* Gets the extended types.

View File

@@ -18,24 +18,18 @@ interface FormTypeGuesserInterface
{
/**
* Returns a field guess for a property name of a class.
*
* @return Guess\TypeGuess|null
*/
public function guessType(string $class, string $property);
public function guessType(string $class, string $property): ?Guess\TypeGuess;
/**
* Returns a guess whether a property of a class is required.
*
* @return Guess\ValueGuess|null
*/
public function guessRequired(string $class, string $property);
public function guessRequired(string $class, string $property): ?Guess\ValueGuess;
/**
* Returns a guess about the field's maximum length.
*
* @return Guess\ValueGuess|null
*/
public function guessMaxLength(string $class, string $property);
public function guessMaxLength(string $class, string $property): ?Guess\ValueGuess;
/**
* Returns a guess about the field's pattern.
@@ -46,8 +40,6 @@ interface FormTypeGuesserInterface
* You want a float greater than 5, 4.512313 is not valid but length(4.512314) > length(5)
*
* @see https://github.com/symfony/symfony/pull/3927
*
* @return Guess\ValueGuess|null
*/
public function guessPattern(string $class, string $property);
public function guessPattern(string $class, string $property): ?Guess\ValueGuess;
}

View File

@@ -26,11 +26,9 @@ interface FormTypeInterface
*
* @param array<string, mixed> $options
*
* @return void
*
* @see FormTypeExtensionInterface::buildForm()
*/
public function buildForm(FormBuilderInterface $builder, array $options);
public function buildForm(FormBuilderInterface $builder, array $options): void;
/**
* Builds the form view.
@@ -44,11 +42,9 @@ interface FormTypeInterface
*
* @param array<string, mixed> $options
*
* @return void
*
* @see FormTypeExtensionInterface::buildView()
*/
public function buildView(FormView $view, FormInterface $form, array $options);
public function buildView(FormView $view, FormInterface $form, array $options): void;
/**
* Finishes the form view.
@@ -63,33 +59,25 @@ interface FormTypeInterface
*
* @param array<string, mixed> $options
*
* @return void
*
* @see FormTypeExtensionInterface::finishView()
*/
public function finishView(FormView $view, FormInterface $form, array $options);
public function finishView(FormView $view, FormInterface $form, array $options): void;
/**
* Configures the options for this type.
*
* @return void
*/
public function configureOptions(OptionsResolver $resolver);
public function configureOptions(OptionsResolver $resolver): void;
/**
* Returns the prefix of the template block name for this type.
*
* The block prefix defaults to the underscored short class name with
* the "Type" suffix removed (e.g. "UserProfileType" => "user_profile").
*
* @return string
*/
public function getBlockPrefix();
public function getBlockPrefix(): string;
/**
* Returns the name of the parent type.
*
* @return string|null
*/
public function getParent();
public function getParent(): ?string;
}

View File

@@ -92,10 +92,7 @@ class FormView implements \ArrayAccess, \IteratorAggregate, \Countable
return $this->methodRendered;
}
/**
* @return void
*/
public function setMethodRendered()
public function setMethodRendered(): void
{
$this->methodRendered = true;
}

View File

@@ -40,11 +40,9 @@ class NativeRequestHandler implements RequestHandlerInterface
}
/**
* @return void
*
* @throws Exception\UnexpectedTypeException If the $request is not null
*/
public function handleRequest(FormInterface $form, mixed $request = null)
public function handleRequest(FormInterface $form, mixed $request = null): void
{
if (null !== $request) {
throw new UnexpectedTypeException($request, 'null');

View File

@@ -20,10 +20,8 @@ interface RequestHandlerInterface
{
/**
* Submits a form if it was submitted.
*
* @return void
*/
public function handleRequest(FormInterface $form, mixed $request = null);
public function handleRequest(FormInterface $form, mixed $request = null): void;
/**
* Returns true if the given data is a file upload.

View File

@@ -92,10 +92,7 @@ class ResolvedFormType implements ResolvedFormTypeInterface
return $this->newView($parent);
}
/**
* @return void
*/
public function buildForm(FormBuilderInterface $builder, array $options)
public function buildForm(FormBuilderInterface $builder, array $options): void
{
$this->parent?->buildForm($builder, $options);
@@ -106,10 +103,7 @@ class ResolvedFormType implements ResolvedFormTypeInterface
}
}
/**
* @return void
*/
public function buildView(FormView $view, FormInterface $form, array $options)
public function buildView(FormView $view, FormInterface $form, array $options): void
{
$this->parent?->buildView($view, $form, $options);
@@ -120,10 +114,7 @@ class ResolvedFormType implements ResolvedFormTypeInterface
}
}
/**
* @return void
*/
public function finishView(FormView $view, FormInterface $form, array $options)
public function finishView(FormView $view, FormInterface $form, array $options): void
{
$this->parent?->finishView($view, $form, $options);

View File

@@ -56,28 +56,22 @@ interface ResolvedFormTypeInterface
/**
* Configures a form builder for the type hierarchy.
*
* @return void
*/
public function buildForm(FormBuilderInterface $builder, array $options);
public function buildForm(FormBuilderInterface $builder, array $options): void;
/**
* Configures a form view for the type hierarchy.
*
* It is called before the children of the view are built.
*
* @return void
*/
public function buildView(FormView $view, FormInterface $form, array $options);
public function buildView(FormView $view, FormInterface $form, array $options): void;
/**
* Finishes a form view for the type hierarchy.
*
* It is called after the children of the view have been built.
*
* @return void
*/
public function finishView(FormView $view, FormInterface $form, array $options);
public function finishView(FormView $view, FormInterface $form, array $options): void;
/**
* Returns the configured options resolver used for this type.

View File

@@ -62,10 +62,7 @@ class OrderedHashMapIterator implements \Iterator
throw new \BadMethodCallException('Cannot serialize '.__CLASS__);
}
/**
* @return void
*/
public function __wakeup()
public function __wakeup(): void
{
throw new \BadMethodCallException('Cannot unserialize '.__CLASS__);
}