Merge branch '7.0' into 7.1

* 7.0:
  List CS fix in .git-blame-ignore-revs
  Fix implicitly-required parameters
  minor #53524 [Messenger] [AmazonSqs] Allow `async-aws/sqs` version 2 (smoench)
  Fix bad merge
  List CS fix in .git-blame-ignore-revs
  Fix implicitly-required parameters
  List CS fix in .git-blame-ignore-revs
  Apply php-cs-fixer fix --rules nullable_type_declaration_for_default_null_value
  [Messenger][AmazonSqs] Allow async-aws/sqs version 2
This commit is contained in:
Nicolas Grekas
2024-01-23 16:06:13 +01:00
61 changed files with 89 additions and 89 deletions

View File

@@ -103,7 +103,7 @@ class Button implements \IteratorAggregate, FormInterface
*
* @throws BadMethodCallException
*/
public function add(string|FormInterface $child, string $type = null, array $options = []): static
public function add(string|FormInterface $child, ?string $type = null, array $options = []): static
{
throw new BadMethodCallException('Buttons cannot have children.');
}
@@ -334,7 +334,7 @@ class Button implements \IteratorAggregate, FormInterface
return null === $this->parent;
}
public function createView(FormView $parent = null): FormView
public function createView(?FormView $parent = null): FormView
{
if (null === $parent && $this->parent) {
$parent = $this->parent->createView();

View File

@@ -53,7 +53,7 @@ class ButtonBuilder implements \IteratorAggregate, FormBuilderInterface
*
* @throws BadMethodCallException
*/
public function add(string|FormBuilderInterface $child, string $type = null, array $options = []): never
public function add(string|FormBuilderInterface $child, ?string $type = null, array $options = []): never
{
throw new BadMethodCallException('Buttons cannot have children.');
}
@@ -63,7 +63,7 @@ class ButtonBuilder implements \IteratorAggregate, FormBuilderInterface
*
* @throws BadMethodCallException
*/
public function create(string $name, string $type = null, array $options = []): never
public function create(string $name, ?string $type = null, array $options = []): never
{
throw new BadMethodCallException('Buttons cannot have children.');
}

View File

@@ -48,7 +48,7 @@ class ArrayChoiceList implements ChoiceListInterface
* incrementing integers are used as
* values
*/
public function __construct(iterable $choices, callable $value = null)
public function __construct(iterable $choices, ?callable $value = null)
{
if ($choices instanceof \Traversable) {
$choices = iterator_to_array($choices);

View File

@@ -26,17 +26,17 @@ use Symfony\Component\Form\FormTypeInterface;
*/
final class ChoiceLoader extends AbstractStaticOption implements ChoiceLoaderInterface
{
public function loadChoiceList(callable $value = null): ChoiceListInterface
public function loadChoiceList(?callable $value = null): ChoiceListInterface
{
return $this->getOption()->loadChoiceList($value);
}
public function loadChoicesForValues(array $values, callable $value = null): array
public function loadChoicesForValues(array $values, ?callable $value = null): array
{
return $this->getOption()->loadChoicesForValues($values, $value);
}
public function loadValuesForChoices(array $choices, callable $value = null): array
public function loadValuesForChoices(array $choices, ?callable $value = null): array
{
return $this->getOption()->loadValuesForChoices($choices, $value);
}

View File

@@ -33,7 +33,7 @@ interface ChoiceListFactoryInterface
*
* @param callable|null $filter The callable filtering the choices
*/
public function createListFromChoices(iterable $choices, callable $value = null, callable $filter = null): ChoiceListInterface;
public function createListFromChoices(iterable $choices, ?callable $value = null, ?callable $filter = null): ChoiceListInterface;
/**
* Creates a choice list that is loaded with the given loader.
@@ -44,7 +44,7 @@ interface ChoiceListFactoryInterface
*
* @param callable|null $filter The callable filtering the choices
*/
public function createListFromLoader(ChoiceLoaderInterface $loader, callable $value = null, callable $filter = null): ChoiceListInterface;
public function createListFromLoader(ChoiceLoaderInterface $loader, ?callable $value = null, ?callable $filter = null): ChoiceListInterface;
/**
* Creates a view for the given choice list.
@@ -81,5 +81,5 @@ interface ChoiceListFactoryInterface
* on top of the list and in their original position
* or only in the top of the list
*/
public function createView(ChoiceListInterface $list, array|callable $preferredChoices = null, callable|false $label = null, callable $index = null, callable $groupBy = null, array|callable $attr = null, array|callable $labelTranslationParameters = [], bool $duplicatePreferredChoices = true): ChoiceListView;
public function createView(ChoiceListInterface $list, array|callable|null $preferredChoices = null, callable|false|null $label = null, ?callable $index = null, ?callable $groupBy = null, array|callable|null $attr = null, array|callable $labelTranslationParameters = [], bool $duplicatePreferredChoices = true): ChoiceListView;
}

View File

@@ -30,7 +30,7 @@ use Symfony\Contracts\Translation\TranslatableInterface;
*/
class DefaultChoiceListFactory implements ChoiceListFactoryInterface
{
public function createListFromChoices(iterable $choices, callable $value = null, callable $filter = null): ChoiceListInterface
public function createListFromChoices(iterable $choices, ?callable $value = null, ?callable $filter = null): ChoiceListInterface
{
if ($filter) {
// filter the choice list lazily
@@ -43,7 +43,7 @@ class DefaultChoiceListFactory implements ChoiceListFactoryInterface
return new ArrayChoiceList($choices, $value);
}
public function createListFromLoader(ChoiceLoaderInterface $loader, callable $value = null, callable $filter = null): ChoiceListInterface
public function createListFromLoader(ChoiceLoaderInterface $loader, ?callable $value = null, ?callable $filter = null): ChoiceListInterface
{
if ($filter) {
$loader = new FilterChoiceLoaderDecorator($loader, $filter);
@@ -52,7 +52,7 @@ class DefaultChoiceListFactory implements ChoiceListFactoryInterface
return new LazyChoiceList($loader, $value);
}
public function createView(ChoiceListInterface $list, array|callable $preferredChoices = null, callable|false $label = null, callable $index = null, callable $groupBy = null, array|callable $attr = null, array|callable $labelTranslationParameters = [], bool $duplicatePreferredChoices = true): ChoiceListView
public function createView(ChoiceListInterface $list, array|callable|null $preferredChoices = null, callable|false|null $label = null, ?callable $index = null, ?callable $groupBy = null, array|callable|null $attr = null, array|callable $labelTranslationParameters = [], bool $duplicatePreferredChoices = true): ChoiceListView
{
$preferredViews = [];
$preferredViewsOrder = [];

View File

@@ -41,7 +41,7 @@ class PropertyAccessDecorator implements ChoiceListFactoryInterface
private ChoiceListFactoryInterface $decoratedFactory;
private PropertyAccessorInterface $propertyAccessor;
public function __construct(ChoiceListFactoryInterface $decoratedFactory, PropertyAccessorInterface $propertyAccessor = null)
public function __construct(ChoiceListFactoryInterface $decoratedFactory, ?PropertyAccessorInterface $propertyAccessor = null)
{
$this->decoratedFactory = $decoratedFactory;
$this->propertyAccessor = $propertyAccessor ?: PropertyAccess::createPropertyAccessor();

View File

@@ -46,7 +46,7 @@ class LazyChoiceList implements ChoiceListInterface
*/
public function __construct(
private ChoiceLoaderInterface $loader,
callable $value = null,
?callable $value = null,
) {
$this->value = null === $value ? null : $value(...);
}

View File

@@ -24,12 +24,12 @@ abstract class AbstractChoiceLoader implements ChoiceLoaderInterface
/**
* @final
*/
public function loadChoiceList(callable $value = null): ChoiceListInterface
public function loadChoiceList(?callable $value = null): ChoiceListInterface
{
return new ArrayChoiceList($this->choices ??= $this->loadChoices(), $value);
}
public function loadChoicesForValues(array $values, callable $value = null): array
public function loadChoicesForValues(array $values, ?callable $value = null): array
{
if (!$values) {
return [];
@@ -38,7 +38,7 @@ abstract class AbstractChoiceLoader implements ChoiceLoaderInterface
return $this->doLoadChoicesForValues($values, $value);
}
public function loadValuesForChoices(array $choices, callable $value = null): array
public function loadValuesForChoices(array $choices, ?callable $value = null): array
{
if (!$choices) {
return [];

View File

@@ -34,7 +34,7 @@ interface ChoiceLoaderInterface
* @param callable|null $value The callable which generates the values
* from choices
*/
public function loadChoiceList(callable $value = null): ChoiceListInterface;
public function loadChoiceList(?callable $value = null): ChoiceListInterface;
/**
* Loads the choices corresponding to the given values.
@@ -50,7 +50,7 @@ interface ChoiceLoaderInterface
* values in this array are ignored
* @param callable|null $value The callable generating the choice values
*/
public function loadChoicesForValues(array $values, callable $value = null): array;
public function loadChoicesForValues(array $values, ?callable $value = null): array;
/**
* Loads the values corresponding to the given choices.
@@ -68,5 +68,5 @@ interface ChoiceLoaderInterface
*
* @return string[]
*/
public function loadValuesForChoices(array $choices, callable $value = null): array;
public function loadValuesForChoices(array $choices, ?callable $value = null): array;
}

View File

@@ -52,12 +52,12 @@ class FilterChoiceLoaderDecorator extends AbstractChoiceLoader
return $choices ?? [];
}
public function loadChoicesForValues(array $values, callable $value = null): array
public function loadChoicesForValues(array $values, ?callable $value = null): array
{
return array_filter($this->decoratedLoader->loadChoicesForValues($values, $value), $this->filter);
}
public function loadValuesForChoices(array $choices, callable $value = null): array
public function loadValuesForChoices(array $choices, ?callable $value = null): array
{
return $this->decoratedLoader->loadValuesForChoices(array_filter($choices, $this->filter), $value);
}

View File

@@ -19,12 +19,12 @@ namespace Symfony\Component\Form\ChoiceList\Loader;
*/
class IntlCallbackChoiceLoader extends CallbackChoiceLoader
{
public function loadChoicesForValues(array $values, callable $value = null): array
public function loadChoicesForValues(array $values, ?callable $value = null): array
{
return parent::loadChoicesForValues(array_filter($values), $value);
}
public function loadValuesForChoices(array $choices, callable $value = null): array
public function loadValuesForChoices(array $choices, ?callable $value = null): array
{
$choices = array_filter($choices);

View File

@@ -188,7 +188,7 @@ class TextDescriptor extends Descriptor
return $options;
}
private function formatClassLink(string $class, string $text = null): string
private function formatClassLink(string $class, ?string $text = null): string
{
$text ??= $class;

View File

@@ -23,7 +23,7 @@ use Symfony\Component\Form\Console\Descriptor\TextDescriptor;
*/
class DescriptorHelper extends BaseDescriptorHelper
{
public function __construct(FileLinkFormatter $fileLinkFormatter = null)
public function __construct(?FileLinkFormatter $fileLinkFormatter = null)
{
$this
->register('txt', new TextDescriptor($fileLinkFormatter))

View File

@@ -21,7 +21,7 @@ class TransformationFailedException extends RuntimeException
private ?string $invalidMessage;
private array $invalidMessageParameters;
public function __construct(string $message = '', int $code = 0, \Throwable $previous = null, string $invalidMessage = null, array $invalidMessageParameters = [])
public function __construct(string $message = '', int $code = 0, ?\Throwable $previous = null, ?string $invalidMessage = null, array $invalidMessageParameters = [])
{
parent::__construct($message, $code, $previous);

View File

@@ -32,8 +32,8 @@ class CoreExtension extends AbstractExtension
private ChoiceListFactoryInterface $choiceListFactory;
public function __construct(
PropertyAccessorInterface $propertyAccessor = null,
ChoiceListFactoryInterface $choiceListFactory = null,
?PropertyAccessorInterface $propertyAccessor = null,
?ChoiceListFactoryInterface $choiceListFactory = null,
private ?TranslatorInterface $translator = null,
) {
$this->propertyAccessor = $propertyAccessor ?: PropertyAccess::createPropertyAccessor();

View File

@@ -31,7 +31,7 @@ class PropertyPathAccessor implements DataAccessorInterface
{
private PropertyAccessorInterface $propertyAccessor;
public function __construct(PropertyAccessorInterface $propertyAccessor = null)
public function __construct(?PropertyAccessorInterface $propertyAccessor = null)
{
$this->propertyAccessor = $propertyAccessor ?? PropertyAccess::createPropertyAccessor();
}

View File

@@ -27,7 +27,7 @@ class DataMapper implements DataMapperInterface
{
private DataAccessorInterface $dataAccessor;
public function __construct(DataAccessorInterface $dataAccessor = null)
public function __construct(?DataAccessorInterface $dataAccessor = null)
{
$this->dataAccessor = $dataAccessor ?? new ChainAccessor([
new CallbackAccessor(),

View File

@@ -38,7 +38,7 @@ abstract class BaseDateTimeTransformer implements DataTransformerInterface
*
* @throws InvalidArgumentException if a timezone is not valid
*/
public function __construct(string $inputTimezone = null, string $outputTimezone = null)
public function __construct(?string $inputTimezone = null, ?string $outputTimezone = null)
{
$this->inputTimezone = $inputTimezone ?: date_default_timezone_get();
$this->outputTimezone = $outputTimezone ?: date_default_timezone_get();

View File

@@ -48,7 +48,7 @@ class DateIntervalToArrayTransformer implements DataTransformerInterface
* @param bool $pad Whether to use padding
*/
public function __construct(
array $fields = null,
?array $fields = null,
private bool $pad = false,
) {
$this->fields = $fields ?? ['years', 'months', 'days', 'hours', 'minutes', 'seconds', 'invert'];

View File

@@ -33,11 +33,11 @@ class DateTimeToArrayTransformer extends BaseDateTimeTransformer
* @param bool $pad Whether to use padding
*/
public function __construct(
string $inputTimezone = null,
string $outputTimezone = null,
array $fields = null,
?string $inputTimezone = null,
?string $outputTimezone = null,
?array $fields = null,
private bool $pad = false,
\DateTimeInterface $referenceDate = null,
?\DateTimeInterface $referenceDate = null,
) {
parent::__construct($inputTimezone, $outputTimezone);

View File

@@ -25,7 +25,7 @@ class DateTimeToHtml5LocalDateTimeTransformer extends BaseDateTimeTransformer
public const HTML5_FORMAT = 'Y-m-d\\TH:i:s';
public const HTML5_FORMAT_NO_SECONDS = 'Y-m-d\\TH:i';
public function __construct(string $inputTimezone = null, string $outputTimezone = null, private bool $withSeconds = false)
public function __construct(?string $inputTimezone = null, ?string $outputTimezone = null, private bool $withSeconds = false)
{
parent::__construct($inputTimezone, $outputTimezone);
}

View File

@@ -40,10 +40,10 @@ class DateTimeToLocalizedStringTransformer extends BaseDateTimeTransformer
* @throws UnexpectedTypeException If a format is not supported or if a timezone is not a string
*/
public function __construct(
string $inputTimezone = null,
string $outputTimezone = null,
int $dateFormat = null,
int $timeFormat = null,
?string $inputTimezone = null,
?string $outputTimezone = null,
?int $dateFormat = null,
?int $timeFormat = null,
private int $calendar = \IntlDateFormatter::GREGORIAN,
private ?string $pattern = null,
) {

View File

@@ -47,7 +47,7 @@ class DateTimeToStringTransformer extends BaseDateTimeTransformer
* @param string $format The date format
* @param string|null $parseFormat The parse format when different from $format
*/
public function __construct(string $inputTimezone = null, string $outputTimezone = null, string $format = 'Y-m-d H:i:s', string $parseFormat = null)
public function __construct(?string $inputTimezone = null, ?string $outputTimezone = null, string $format = 'Y-m-d H:i:s', ?string $parseFormat = null)
{
parent::__construct($inputTimezone, $outputTimezone);

View File

@@ -28,7 +28,7 @@ class IntegerToLocalizedStringTransformer extends NumberToLocalizedStringTransfo
* @param int|null $roundingMode One of the ROUND_ constants in this class
* @param string|null $locale locale used for transforming
*/
public function __construct(?bool $grouping = false, ?int $roundingMode = \NumberFormatter::ROUND_DOWN, string $locale = null)
public function __construct(?bool $grouping = false, ?int $roundingMode = \NumberFormatter::ROUND_DOWN, ?string $locale = null)
{
parent::__construct(0, $grouping, $roundingMode, $locale);
}

View File

@@ -28,7 +28,7 @@ class MoneyToLocalizedStringTransformer extends NumberToLocalizedStringTransform
?bool $grouping = true,
?int $roundingMode = \NumberFormatter::ROUND_HALFUP,
?int $divisor = 1,
string $locale = null,
?string $locale = null,
private string $modelType = 'float',
) {
parent::__construct($scale ?? 2, $grouping ?? true, $roundingMode, $locale);

View File

@@ -45,8 +45,8 @@ class PercentToLocalizedStringTransformer implements DataTransformerInterface
* @throws UnexpectedTypeException if the given value of type is unknown
*/
public function __construct(
int $scale = null,
string $type = null,
?int $scale = null,
?string $type = null,
private int $roundingMode = \NumberFormatter::ROUND_HALFUP,
private bool $html5Format = false,
) {

View File

@@ -34,7 +34,7 @@ class ResizeFormListener implements EventSubscriberInterface
private bool $allowAdd = false,
private bool $allowDelete = false,
bool|callable $deleteEmpty = false,
array $prototypeOptions = null,
?array $prototypeOptions = null,
private bool $keepAsList = false,
) {
$this->deleteEmpty = \is_bool($deleteEmpty) ? $deleteEmpty : $deleteEmpty(...);

View File

@@ -53,7 +53,7 @@ class ChoiceType extends AbstractType
private ChoiceListFactoryInterface $choiceListFactory;
private ?TranslatorInterface $translator;
public function __construct(ChoiceListFactoryInterface $choiceListFactory = null, TranslatorInterface $translator = null)
public function __construct(?ChoiceListFactoryInterface $choiceListFactory = null, ?TranslatorInterface $translator = null)
{
$this->choiceListFactory = $choiceListFactory ?? new CachingFactoryDecorator(
new PropertyAccessDecorator(

View File

@@ -30,7 +30,7 @@ class FormType extends BaseType
{
private DataMapper $dataMapper;
public function __construct(PropertyAccessorInterface $propertyAccessor = null)
public function __construct(?PropertyAccessorInterface $propertyAccessor = null)
{
$this->dataMapper = new DataMapper(new ChainAccessor([
new CallbackAccessor(),

View File

@@ -106,7 +106,7 @@ class TimezoneType extends AbstractType
return $timezones;
}
private static function getIntlTimezones(string $input, string $locale = null): array
private static function getIntlTimezones(string $input, ?string $locale = null): array
{
$timezones = array_flip(Timezones::getNames($locale));

View File

@@ -41,7 +41,7 @@ class CsrfValidationListener implements EventSubscriberInterface
private string $errorMessage,
private ?TranslatorInterface $translator = null,
private ?string $translationDomain = null,
ServerParams $serverParams = null,
?ServerParams $serverParams = null,
)
{
$this->serverParams = $serverParams ?? new ServerParams();

View File

@@ -73,7 +73,7 @@ class FormDataCollector extends DataCollector implements FormDataCollectorInterf
/**
* Does nothing. The data is collected during the form event listeners.
*/
public function collect(Request $request, Response $response, \Throwable $exception = null): void
public function collect(Request $request, Response $response, ?\Throwable $exception = null): void
{
}

View File

@@ -63,7 +63,7 @@ class ResolvedTypeDataCollectorProxy implements ResolvedFormTypeInterface
return $builder;
}
public function createView(FormInterface $form, FormView $parent = null): FormView
public function createView(FormInterface $form, ?FormView $parent = null): FormView
{
return $this->proxiedType->createView($form, $parent);
}

View File

@@ -30,7 +30,7 @@ class ResolvedTypeFactoryDataCollectorProxy implements ResolvedFormTypeFactoryIn
) {
}
public function createResolvedType(FormTypeInterface $type, array $typeExtensions, ResolvedFormTypeInterface $parent = null): ResolvedFormTypeInterface
public function createResolvedType(FormTypeInterface $type, array $typeExtensions, ?ResolvedFormTypeInterface $parent = null): ResolvedFormTypeInterface
{
return new ResolvedTypeDataCollectorProxy(
$this->proxiedFactory->createResolvedType($type, $typeExtensions, $parent),

View File

@@ -31,7 +31,7 @@ class HttpFoundationRequestHandler implements RequestHandlerInterface
{
private ServerParams $serverParams;
public function __construct(ServerParams $serverParams = null)
public function __construct(?ServerParams $serverParams = null)
{
$this->serverParams = $serverParams ?? new ServerParams();
}

View File

@@ -24,7 +24,7 @@ class FormTypeHttpFoundationExtension extends AbstractTypeExtension
{
private RequestHandlerInterface $requestHandler;
public function __construct(RequestHandlerInterface $requestHandler = null)
public function __construct(?RequestHandlerInterface $requestHandler = null)
{
$this->requestHandler = $requestHandler ?? new HttpFoundationRequestHandler();
}

View File

@@ -32,8 +32,8 @@ class FormTypeValidatorExtension extends BaseValidatorExtension
public function __construct(
private ValidatorInterface $validator,
private bool $legacyErrorMessages = true,
FormRendererInterface $formRenderer = null,
TranslatorInterface $translator = null,
?FormRendererInterface $formRenderer = null,
?TranslatorInterface $translator = null,
) {
$this->violationMapper = new ViolationMapper($formRenderer, $translator);
}

View File

@@ -714,7 +714,7 @@ class Form implements \IteratorAggregate, FormInterface, ClearableErrorsInterfac
return iterator_to_array($this->children);
}
public function add(FormInterface|string $child, string $type = null, array $options = []): static
public function add(FormInterface|string $child, ?string $type = null, array $options = []): static
{
if ($this->submitted) {
throw new AlreadySubmittedException('You cannot add children to a submitted form.');
@@ -871,7 +871,7 @@ class Form implements \IteratorAggregate, FormInterface, ClearableErrorsInterfac
return \count($this->children);
}
public function createView(FormView $parent = null): FormView
public function createView(?FormView $parent = null): FormView
{
if (null === $parent && $this->parent) {
$parent = $this->parent->createView();

View File

@@ -44,7 +44,7 @@ class FormBuilder extends FormConfigBuilder implements \IteratorAggregate, FormB
$this->setFormFactory($factory);
}
public function add(FormBuilderInterface|string $child, string $type = null, array $options = []): static
public function add(FormBuilderInterface|string $child, ?string $type = null, array $options = []): static
{
if ($this->locked) {
throw new BadMethodCallException('FormBuilder methods cannot be accessed anymore once the builder is turned into a FormConfigInterface instance.');
@@ -66,7 +66,7 @@ class FormBuilder extends FormConfigBuilder implements \IteratorAggregate, FormB
return $this;
}
public function create(string $name, string $type = null, array $options = []): FormBuilderInterface
public function create(string $name, ?string $type = null, array $options = []): FormBuilderInterface
{
if ($this->locked) {
throw new BadMethodCallException('FormBuilder methods cannot be accessed anymore once the builder is turned into a FormConfigInterface instance.');

View File

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

View File

@@ -42,7 +42,7 @@ class FormError
*/
public function __construct(
private string $message,
string $messageTemplate = null,
?string $messageTemplate = null,
protected array $messageParameters = [],
protected ?int $messagePluralization = null,
private mixed $cause = null,

View File

@@ -54,7 +54,7 @@ interface FormInterface extends \ArrayAccess, \Traversable, \Countable
* @throws Exception\LogicException when trying to add a child to a non-compound form
* @throws Exception\UnexpectedTypeException if $child or $type has an unexpected type
*/
public function add(self|string $child, string $type = null, array $options = []): static;
public function add(self|string $child, ?string $type = null, array $options = []): static;
/**
* Returns the child with the given name.
@@ -285,5 +285,5 @@ interface FormInterface extends \ArrayAccess, \Traversable, \Countable
*/
public function isRoot(): bool;
public function createView(FormView $parent = null): FormView;
public function createView(?FormView $parent = null): FormView;
}

View File

@@ -36,7 +36,7 @@ class NativeRequestHandler implements RequestHandlerInterface
'type',
];
public function __construct(ServerParams $params = null)
public function __construct(?ServerParams $params = null)
{
$this->serverParams = $params ?? new ServerParams();
}

View File

@@ -84,7 +84,7 @@ class ResolvedFormType implements ResolvedFormTypeInterface
return $builder;
}
public function createView(FormInterface $form, FormView $parent = null): FormView
public function createView(FormInterface $form, ?FormView $parent = null): FormView
{
return $this->newView($parent);
}
@@ -165,7 +165,7 @@ class ResolvedFormType implements ResolvedFormTypeInterface
*
* Override this method if you want to customize the view class.
*/
protected function newView(FormView $parent = null): FormView
protected function newView(?FormView $parent = null): FormView
{
return new FormView($parent);
}

View File

@@ -16,7 +16,7 @@ namespace Symfony\Component\Form;
*/
class ResolvedFormTypeFactory implements ResolvedFormTypeFactoryInterface
{
public function createResolvedType(FormTypeInterface $type, array $typeExtensions, ResolvedFormTypeInterface $parent = null): ResolvedFormTypeInterface
public function createResolvedType(FormTypeInterface $type, array $typeExtensions, ?ResolvedFormTypeInterface $parent = null): ResolvedFormTypeInterface
{
return new ResolvedFormType($type, $typeExtensions, $parent);
}

View File

@@ -30,5 +30,5 @@ interface ResolvedFormTypeFactoryInterface
* @throws Exception\UnexpectedTypeException if the types parent {@link FormTypeInterface::getParent()} is not a string
* @throws Exception\InvalidArgumentException if the types parent cannot be retrieved from any extension
*/
public function createResolvedType(FormTypeInterface $type, array $typeExtensions, ResolvedFormTypeInterface $parent = null): ResolvedFormTypeInterface;
public function createResolvedType(FormTypeInterface $type, array $typeExtensions, ?ResolvedFormTypeInterface $parent = null): ResolvedFormTypeInterface;
}

View File

@@ -52,7 +52,7 @@ interface ResolvedFormTypeInterface
/**
* Creates a new form view for a form of this type.
*/
public function createView(FormInterface $form, FormView $parent = null): FormView;
public function createView(FormInterface $form, ?FormView $parent = null): FormView;
/**
* Configures a form builder for the type hierarchy.

View File

@@ -729,7 +729,7 @@ class DefaultChoiceListFactoryTest extends TestCase
public function testPassTranslatableInterfaceAsLabelDoesntCastItToString()
{
$message = new class() implements TranslatableInterface {
public function trans(TranslatorInterface $translator, string $locale = null): string
public function trans(TranslatorInterface $translator, ?string $locale = null): string
{
return 'my_message';
}

View File

@@ -1117,7 +1117,7 @@ class CompoundFormTest extends TestCase
return $builder->getForm();
}
private function getBuilder(string $name = 'name', string $dataClass = null, array $options = []): FormBuilder
private function getBuilder(string $name = 'name', ?string $dataClass = null, array $options = []): FormBuilder
{
return new FormBuilder($name, $dataClass, new EventDispatcher(), $this->factory, $options);
}

View File

@@ -31,5 +31,5 @@ abstract class BaseDateTimeTransformerTestCase extends TestCase
$this->createDateTimeTransformer(null, 'that_timezone_does_not_exist');
}
abstract protected function createDateTimeTransformer(string $inputTimezone = null, string $outputTimezone = null): BaseDateTimeTransformer;
abstract protected function createDateTimeTransformer(?string $inputTimezone = null, ?string $outputTimezone = null): BaseDateTimeTransformer;
}

View File

@@ -536,7 +536,7 @@ class DateTimeToArrayTransformerTest extends BaseDateTimeTransformerTestCase
]);
}
protected function createDateTimeTransformer(string $inputTimezone = null, string $outputTimezone = null): BaseDateTimeTransformer
protected function createDateTimeTransformer(?string $inputTimezone = null, ?string $outputTimezone = null): BaseDateTimeTransformer
{
return new DateTimeToArrayTransformer($inputTimezone, $outputTimezone);
}

View File

@@ -120,7 +120,7 @@ class DateTimeToHtml5LocalDateTimeTransformerTest extends BaseDateTimeTransforme
$transformer->reverseTransform('2010-2010-2010');
}
protected function createDateTimeTransformer(string $inputTimezone = null, string $outputTimezone = null): BaseDateTimeTransformer
protected function createDateTimeTransformer(?string $inputTimezone = null, ?string $outputTimezone = null): BaseDateTimeTransformer
{
return new DateTimeToHtml5LocalDateTimeTransformer($inputTimezone, $outputTimezone);
}

View File

@@ -371,7 +371,7 @@ class DateTimeToLocalizedStringTransformerTest extends BaseDateTimeTransformerTe
$transformer->reverseTransform('12345');
}
protected function createDateTimeTransformer(string $inputTimezone = null, string $outputTimezone = null): BaseDateTimeTransformer
protected function createDateTimeTransformer(?string $inputTimezone = null, ?string $outputTimezone = null): BaseDateTimeTransformer
{
return new DateTimeToLocalizedStringTransformer($inputTimezone, $outputTimezone);
}

View File

@@ -138,7 +138,7 @@ class DateTimeToRfc3339TransformerTest extends BaseDateTimeTransformerTestCase
];
}
protected function createDateTimeTransformer(string $inputTimezone = null, string $outputTimezone = null): BaseDateTimeTransformer
protected function createDateTimeTransformer(?string $inputTimezone = null, ?string $outputTimezone = null): BaseDateTimeTransformer
{
return new DateTimeToRfc3339Transformer($inputTimezone, $outputTimezone);
}

View File

@@ -171,7 +171,7 @@ class DateTimeToStringTransformerTest extends BaseDateTimeTransformerTestCase
$reverseTransformer->reverseTransform('2010-04-31');
}
protected function createDateTimeTransformer(string $inputTimezone = null, string $outputTimezone = null): BaseDateTimeTransformer
protected function createDateTimeTransformer(?string $inputTimezone = null, ?string $outputTimezone = null): BaseDateTimeTransformer
{
return new DateTimeToStringTransformer($inputTimezone, $outputTimezone);
}

View File

@@ -115,7 +115,7 @@ class DateTimeToTimestampTransformerTest extends BaseDateTimeTransformerTestCase
$reverseTransformer->reverseTransform('2010-2010-2010');
}
protected function createDateTimeTransformer(string $inputTimezone = null, string $outputTimezone = null): BaseDateTimeTransformer
protected function createDateTimeTransformer(?string $inputTimezone = null, ?string $outputTimezone = null): BaseDateTimeTransformer
{
return new DateTimeToTimestampTransformer($inputTimezone, $outputTimezone);
}

View File

@@ -71,7 +71,7 @@ class StringToFloatTransformerTest extends TestCase
/**
* @dataProvider provideReverseTransformations
*/
public function testReverseTransform($from, $to, int $scale = null)
public function testReverseTransform($from, $to, ?int $scale = null)
{
$transformer = new StringToFloatTransformer($scale);

View File

@@ -120,7 +120,7 @@ class CollectionTypeTest extends BaseTypeTestCase
$form = $this->factory->create(static::TESTED_TYPE, null, [
'entry_type' => AuthorType::class,
'allow_delete' => true,
'delete_empty' => fn (Author $obj = null) => null === $obj || empty($obj->firstName),
'delete_empty' => fn (?Author $obj = null) => null === $obj || empty($obj->firstName),
]);
$form->setData([new Author('Bob'), new Author('Alice')]);

View File

@@ -707,7 +707,7 @@ class FormValidatorTest extends ConstraintValidatorTestCase
return new FormValidator();
}
private function getBuilder(string $name = 'name', string $dataClass = null, array $options = []): FormBuilder
private function getBuilder(string $name = 'name', ?string $dataClass = null, array $options = []): FormBuilder
{
$options = array_replace([
'constraints' => [],

View File

@@ -1128,7 +1128,7 @@ class SimpleFormTest extends TestCase
return $this->getBuilder()->getForm();
}
private function getBuilder(?string $name = 'name', string $dataClass = null, array $options = []): FormBuilder
private function getBuilder(?string $name = 'name', ?string $dataClass = null, array $options = []): FormBuilder
{
return new FormBuilder($name, $dataClass, new EventDispatcher(), new FormFactory(new FormRegistry([], new ResolvedFormTypeFactory())), $options);
}