Skip to content

[Validator] remove docblocks for deprecated argument types #61240

New issue

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

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

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 26, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 16 additions & 21 deletions UPGRADE-7.4.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,16 +85,14 @@ Validator

class CustomConstraint extends Constraint
{
public $option1;
public $option2;

#[HasNamedArguments]
public function __construct($option1 = null, $option2 = null, ?array $groups = null, mixed $payload = null)
{
public function __construct(
public $option1 = null,
public $option2 = null,
?array $groups = null,
mixed $payload = null,
) {
parent::__construct(null, $groups, $payload);

$this->option1 = $option1;
$this->option2 = $option2;
}
}
```
Expand Down Expand Up @@ -128,16 +126,14 @@ Validator

class CustomConstraint extends Constraint
{
public $option1;
public $option2;

#[HasNamedArguments]
public function __construct($option1, $option2 = null, ?array $groups = null, mixed $payload = null)
{
public function __construct(
public $option1,
public $option2 = null,
?array $groups = null,
mixed $payload = null,
) {
parent::__construct(null, $groups, $payload);

$this->option1 = $option1;
$this->option2 = $option2;
}
}
```
Expand Down Expand Up @@ -172,13 +168,12 @@ Validator

class CustomCompositeConstraint extends Composite
{
public array $constraints = [];

#[HasNamedArguments]
public function __construct(array $constraints, ?array $groups = null, mixed $payload = null)
public function __construct(
public array $constraints,
?array $groups = null,
mixed $payload = null)
{
$this->constraints = $constraints;

parent::__construct(null, $groups, $payload);
}
}
Expand Down
37 changes: 16 additions & 21 deletions src/Symfony/Component/Validator/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,16 +31,14 @@ CHANGELOG

class CustomConstraint extends Constraint
{
public $option1;
public $option2;

#[HasNamedArguments]
public function __construct($option1 = null, $option2 = null, ?array $groups = null, mixed $payload = null)
{
public function __construct(
public $option1 = null,
public $option2 = null,
?array $groups = null,
mixed $payload = null,
) {
parent::__construct(null, $groups, $payload);

$this->option1 = $option1;
$this->option2 = $option2;
}
}
```
Expand Down Expand Up @@ -74,16 +72,14 @@ CHANGELOG

class CustomConstraint extends Constraint
{
public $option1;
public $option2;

#[HasNamedArguments]
public function __construct($option1, $option2 = null, ?array $groups = null, mixed $payload = null)
{
public function __construct(
public $option1,
public $option2 = null,
?array $groups = null,
mixed $payload = null,
) {
parent::__construct(null, $groups, $payload);

$this->option1 = $option1;
$this->option2 = $option2;
}
}
```
Expand Down Expand Up @@ -118,13 +114,12 @@ CHANGELOG

class CustomCompositeConstraint extends Composite
{
public array $constraints = [];

#[HasNamedArguments]
public function __construct(array $constraints, ?array $groups = null, mixed $payload = null)
public function __construct(
public array $constraints,
?array $groups = null,
mixed $payload = null)
{
$this->constraints = $constraints;

parent::__construct(null, $groups, $payload);
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/Symfony/Component/Validator/Constraints/All.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ class All extends Composite
public array|Constraint $constraints = [];

/**
* @param array<Constraint>|array<string,mixed>|Constraint|null $constraints
* @param string[]|null $groups
* @param array<Constraint>|Constraint|null $constraints
* @param string[]|null $groups
*/
#[HasNamedArguments]
public function __construct(mixed $constraints = null, ?array $groups = null, mixed $payload = null)
Expand Down
10 changes: 5 additions & 5 deletions src/Symfony/Component/Validator/Constraints/AtLeastOneOf.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,11 @@ class AtLeastOneOf extends Composite
public bool $includeInternalMessages = true;

/**
* @param array<Constraint>|array<string,mixed>|null $constraints An array of validation constraints
* @param string[]|null $groups
* @param string|null $message Intro of the failure message that will be followed by the failed constraint(s) message(s)
* @param string|null $messageCollection Failure message for All and Collection inner constraints
* @param bool|null $includeInternalMessages Whether to include inner constraint messages (defaults to true)
* @param array<Constraint>|null $constraints An array of validation constraints
* @param string[]|null $groups
* @param string|null $message Intro of the failure message that will be followed by the failed constraint(s) message(s)
* @param string|null $messageCollection Failure message for All and Collection inner constraints
* @param bool|null $includeInternalMessages Whether to include inner constraint messages (defaults to true)
*/
#[HasNamedArguments]
public function __construct(mixed $constraints = null, ?array $groups = null, mixed $payload = null, ?string $message = null, ?string $messageCollection = null, ?bool $includeInternalMessages = null)
Expand Down
1 change: 0 additions & 1 deletion src/Symfony/Component/Validator/Constraints/Bic.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@ class Bic extends Constraint
public string $mode = self::VALIDATION_MODE_STRICT;

/**
* @param array<string,mixed>|null $options
* @param string|null $iban An IBAN value to validate that its country code is the same as the BIC's one
* @param string|null $ibanPropertyPath Property path to the IBAN value when validating objects
* @param string[]|null $groups
Expand Down
3 changes: 1 addition & 2 deletions src/Symfony/Component/Validator/Constraints/Blank.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,7 @@ class Blank extends Constraint
public string $message = 'This value should be blank.';

/**
* @param array<string,mixed>|null $options
* @param string[]|null $groups
* @param string[]|null $groups
*/
#[HasNamedArguments]
public function __construct(?array $options = null, ?string $message = null, ?array $groups = null, mixed $payload = null)
Expand Down
4 changes: 2 additions & 2 deletions src/Symfony/Component/Validator/Constraints/Callback.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ class Callback extends Constraint
public $callback;

/**
* @param string|string[]|callable|array<string,mixed>|null $callback The callback definition
* @param string[]|null $groups
* @param string|string[]|callable|null $callback The callback definition
* @param string[]|null $groups
*/
#[HasNamedArguments]
public function __construct(array|string|callable|null $callback = null, ?array $groups = null, mixed $payload = null, ?array $options = null)
Expand Down
5 changes: 2 additions & 3 deletions src/Symfony/Component/Validator/Constraints/CardScheme.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,8 @@ class CardScheme extends Constraint
public array|string|null $schemes = null;

/**
* @param non-empty-string|non-empty-string[]|array<string,mixed>|null $schemes Name(s) of the number scheme(s) used to validate the credit card number
* @param string[]|null $groups
* @param array<string,mixed>|null $options
* @param non-empty-string|non-empty-string[]|null $schemes Name(s) of the number scheme(s) used to validate the credit card number
* @param string[]|null $groups
*/
#[HasNamedArguments]
public function __construct(array|string|null $schemes, ?string $message = null, ?array $groups = null, mixed $payload = null, ?array $options = null)
Expand Down
3 changes: 1 addition & 2 deletions src/Symfony/Component/Validator/Constraints/Cascade.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,7 @@ class Cascade extends Constraint
public array $exclude = [];

/**
* @param non-empty-string[]|non-empty-string|array<string,mixed>|null $exclude Properties excluded from validation
* @param array<string,mixed>|null $options
* @param non-empty-string[]|non-empty-string|null $exclude Properties excluded from validation
*/
#[HasNamedArguments]
public function __construct(array|string|null $exclude = null, ?array $options = null)
Expand Down
8 changes: 4 additions & 4 deletions src/Symfony/Component/Validator/Constraints/Collection.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,10 @@ class Collection extends Composite
public string $missingFieldsMessage = 'This field is missing.';

/**
* @param array<string,Constraint>|array<string,mixed>|null $fields An associative array defining keys in the collection and their constraints
* @param string[]|null $groups
* @param bool|null $allowExtraFields Whether to allow additional keys not declared in the configured fields (defaults to false)
* @param bool|null $allowMissingFields Whether to allow the collection to lack some fields declared in the configured fields (defaults to false)
* @param array<string,Constraint>|null $fields An associative array defining keys in the collection and their constraints
* @param string[]|null $groups
* @param bool|null $allowExtraFields Whether to allow additional keys not declared in the configured fields (defaults to false)
* @param bool|null $allowMissingFields Whether to allow the collection to lack some fields declared in the configured fields (defaults to false)
*/
#[HasNamedArguments]
public function __construct(mixed $fields = null, ?array $groups = null, mixed $payload = null, ?bool $allowExtraFields = null, ?bool $allowMissingFields = null, ?string $extraFieldsMessage = null, ?string $missingFieldsMessage = null)
Expand Down
12 changes: 6 additions & 6 deletions src/Symfony/Component/Validator/Constraints/Count.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,12 @@
public ?int $divisibleBy = null;

/**
* @param int<0, max>|array<string,mixed>|null $exactly The exact expected number of elements
* @param int<0, max>|null $min Minimum expected number of elements
* @param int<0, max>|null $max Maximum expected number of elements
* @param positive-int|null $divisibleBy The number the collection count should be divisible by
* @param string[]|null $groups
* @param array<mixed,string>|null $options
* @param int<0, max>|null $exactly The exact expected number of elements
* @param int<0, max>|null $min Minimum expected number of elements
* @param int<0, max>|null $max Maximum expected number of elements
* @param positive-int|null $divisibleBy The number the collection count should be divisible by
* @param string[]|null $groups
* @param array<mixed,string>|null $options
*/
#[HasNamedArguments]
public function __construct(
Expand All @@ -68,7 +68,7 @@
if (\is_array($exactly)) {
trigger_deprecation('symfony/validator', '7.3', 'Passing an array of options to configure the "%s" constraint is deprecated, use named arguments instead.', static::class);

$options = array_merge($exactly, $options ?? []);

Check failure on line 71 in src/Symfony/Component/Validator/Constraints/Count.php

View workflow job for this annotation

GitHub Actions / Psalm

NoValue

src/Symfony/Component/Validator/Constraints/Count.php:71:36: NoValue: All possible types for this argument were invalidated - This may be dead code (see https://psalm.dev/179)
$exactly = $options['value'] ?? null;
} elseif (\is_array($options)) {
trigger_deprecation('symfony/validator', '7.3', 'Passing an array of options to configure the "%s" constraint is deprecated, use named arguments instead.', static::class);
Expand Down
5 changes: 2 additions & 3 deletions src/Symfony/Component/Validator/Constraints/Country.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,8 @@ class Country extends Constraint
public bool $alpha3 = false;

/**
* @param array<string,mixed>|null $options
* @param bool|null $alpha3 Whether to check for alpha-3 codes instead of alpha-2 (defaults to false)
* @param string[]|null $groups
* @param bool|null $alpha3 Whether to check for alpha-3 codes instead of alpha-2 (defaults to false)
* @param string[]|null $groups
*
* @see https://en.wikipedia.org/wiki/ISO_3166-1_alpha-3#Current_codes
*/
Expand Down
5 changes: 2 additions & 3 deletions src/Symfony/Component/Validator/Constraints/CssColor.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,8 @@ class CssColor extends Constraint
public array|string $formats;

/**
* @param non-empty-string[]|non-empty-string|array<string,mixed> $formats The types of CSS colors allowed ({@see https://symfony.com/doc/current/reference/constraints/CssColor.html#formats})
* @param string[]|null $groups
* @param array<string,mixed>|null $options
* @param non-empty-string[]|non-empty-string $formats The types of CSS colors allowed ({@see https://symfony.com/doc/current/reference/constraints/CssColor.html#formats})
* @param string[]|null $groups
*/
#[HasNamedArguments]
public function __construct(array|string $formats = [], ?string $message = null, ?array $groups = null, $payload = null, ?array $options = null)
Expand Down
3 changes: 1 addition & 2 deletions src/Symfony/Component/Validator/Constraints/Currency.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,7 @@ class Currency extends Constraint
public string $message = 'This value is not a valid currency.';

/**
* @param array<string,mixed>|null $options
* @param string[]|null $groups
* @param string[]|null $groups
*/
#[HasNamedArguments]
public function __construct(?array $options = null, ?string $message = null, ?array $groups = null, mixed $payload = null)
Expand Down
3 changes: 1 addition & 2 deletions src/Symfony/Component/Validator/Constraints/Date.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,7 @@ class Date extends Constraint
public string $message = 'This value is not a valid date.';

/**
* @param array<string,mixed>|null $options
* @param string[]|null $groups
* @param string[]|null $groups
*/
#[HasNamedArguments]
public function __construct(?array $options = null, ?string $message = null, ?array $groups = null, mixed $payload = null)
Expand Down
5 changes: 2 additions & 3 deletions src/Symfony/Component/Validator/Constraints/DateTime.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,8 @@
public string $message = 'This value is not a valid datetime.';

/**
* @param non-empty-string|array<string,mixed>|null $format The datetime format to match (defaults to 'Y-m-d H:i:s')
* @param string[]|null $groups
* @param array<string,mixed>|null $options
* @param non-empty-string|null $format The datetime format to match (defaults to 'Y-m-d H:i:s')
* @param string[]|null $groups
*/
#[HasNamedArguments]
public function __construct(string|array|null $format = null, ?string $message = null, ?array $groups = null, mixed $payload = null, ?array $options = null)
Expand All @@ -48,7 +47,7 @@
if (\is_array($format)) {
trigger_deprecation('symfony/validator', '7.3', 'Passing an array of options to configure the "%s" constraint is deprecated, use named arguments instead.', static::class);

$options = array_merge($format, $options ?? []);

Check failure on line 50 in src/Symfony/Component/Validator/Constraints/DateTime.php

View workflow job for this annotation

GitHub Actions / Psalm

NoValue

src/Symfony/Component/Validator/Constraints/DateTime.php:50:36: NoValue: All possible types for this argument were invalidated - This may be dead code (see https://psalm.dev/179)
} elseif (null !== $format) {
if (\is_array($options)) {
trigger_deprecation('symfony/validator', '7.3', 'Passing an array of options to configure the "%s" constraint is deprecated, use named arguments instead.', static::class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,6 @@
#[\Attribute(\Attribute::TARGET_PROPERTY | \Attribute::TARGET_METHOD | \Attribute::TARGET_CLASS)]
class DisableAutoMapping extends Constraint
{
/**
* @param array<string,mixed>|null $options
*/
#[HasNamedArguments]
public function __construct(?array $options = null, mixed $payload = null)
{
Expand Down
3 changes: 1 addition & 2 deletions src/Symfony/Component/Validator/Constraints/Email.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,7 @@ class Email extends Constraint
public $normalizer;

/**
* @param array<string,mixed>|null $options
* @param self::VALIDATION_MODE_*|null $mode The pattern used to validate the email address; pass null to use the default mode configured for the EmailValidator
* @param self::VALIDATION_MODE_*|null $mode The pattern used to validate the email address; pass null to use the default mode configured for the EmailValidator
* @param string[]|null $groups
*/
#[HasNamedArguments]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,6 @@
#[\Attribute(\Attribute::TARGET_PROPERTY | \Attribute::TARGET_METHOD | \Attribute::TARGET_CLASS)]
class EnableAutoMapping extends Constraint
{
/**
* @param array<string,mixed>|null $options
*/
#[HasNamedArguments]
public function __construct(?array $options = null, mixed $payload = null)
{
Expand Down
9 changes: 4 additions & 5 deletions src/Symfony/Component/Validator/Constraints/Expression.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,10 @@
public bool $negate = true;

/**
* @param string|ExpressionObject|array<string,mixed>|null $expression The expression to evaluate
* @param array<string,mixed>|null $values The values of the custom variables used in the expression (defaults to an empty array)
* @param string[]|null $groups
* @param array<string,mixed>|null $options
* @param bool|null $negate Whether to fail if the expression evaluates to true (defaults to false)
* @param string|ExpressionObject|null $expression The expression to evaluate
* @param array<string,mixed>|null $values The values of the custom variables used in the expression (defaults to an empty array)
* @param string[]|null $groups
* @param bool|null $negate Whether to fail if the expression evaluates to true (defaults to false)
*/
#[HasNamedArguments]
public function __construct(
Expand All @@ -68,7 +67,7 @@
if (\is_array($expression)) {
trigger_deprecation('symfony/validator', '7.3', 'Passing an array of options to configure the "%s" constraint is deprecated, use named arguments instead.', static::class);

$options = array_merge($expression, $options ?? []);

Check failure on line 70 in src/Symfony/Component/Validator/Constraints/Expression.php

View workflow job for this annotation

GitHub Actions / Psalm

NoValue

src/Symfony/Component/Validator/Constraints/Expression.php:70:36: NoValue: All possible types for this argument were invalidated - This may be dead code (see https://psalm.dev/179)
$expression = null;
} else {
if (\is_array($options)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,9 @@ class ExpressionSyntax extends Constraint
public ?array $allowedVariables = null;

/**
* @param array<string,mixed>|null $options
* @param non-empty-string|null $service The service used to validate the constraint instead of the default one
* @param string[]|null $allowedVariables Restrict the available variables in the expression to these values (defaults to null that allows any variable)
* @param string[]|null $groups
* @param non-empty-string|null $service The service used to validate the constraint instead of the default one
* @param string[]|null $allowedVariables Restrict the available variables in the expression to these values (defaults to null that allows any variable)
* @param string[]|null $groups
*/
#[HasNamedArguments]
public function __construct(?array $options = null, ?string $message = null, ?string $service = null, ?array $allowedVariables = null, ?array $groups = null, mixed $payload = null)
Expand Down
1 change: 0 additions & 1 deletion src/Symfony/Component/Validator/Constraints/File.php
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,6 @@ class File extends Constraint
protected int|string|null $maxSize = null;

/**
* @param array<string,mixed>|null $options
* @param positive-int|string|null $maxSize The max size of the underlying file
* @param bool|null $binaryFormat Pass true to use binary-prefixed units (KiB, MiB, etc.) or false to use SI-prefixed units (kB, MB) in displayed messages. Pass null to guess the format from the maxSize option. (defaults to null)
* @param string[]|string|null $mimeTypes Acceptable media type(s). Prefer the extensions option that also enforce the file's extension consistency.
Expand Down
5 changes: 2 additions & 3 deletions src/Symfony/Component/Validator/Constraints/Hostname.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,8 @@ class Hostname extends Constraint
public bool $requireTld = true;

/**
* @param array<string,mixed>|null $options
* @param bool|null $requireTld Whether to require the hostname to include its top-level domain (defaults to true)
* @param string[]|null $groups
* @param bool|null $requireTld Whether to require the hostname to include its top-level domain (defaults to true)
* @param string[]|null $groups
*/
#[HasNamedArguments]
public function __construct(
Expand Down
3 changes: 1 addition & 2 deletions src/Symfony/Component/Validator/Constraints/Iban.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,7 @@ class Iban extends Constraint
public string $message = 'This is not a valid International Bank Account Number (IBAN).';

/**
* @param array<string,mixed>|null $options
* @param string[]|null $groups
* @param string[]|null $groups
*/
#[HasNamedArguments]
public function __construct(?array $options = null, ?string $message = null, ?array $groups = null, mixed $payload = null)
Expand Down
1 change: 0 additions & 1 deletion src/Symfony/Component/Validator/Constraints/Image.php
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,6 @@ class Image extends File
public string $corruptedMessage = 'The image file is corrupted.';

/**
* @param array<string,mixed>|null $options
* @param positive-int|string|null $maxSize The max size of the underlying file
* @param bool|null $binaryFormat Pass true to use binary-prefixed units (KiB, MiB, etc.) or false to use SI-prefixed units (kB, MB) in displayed messages. Pass null to guess the format from the maxSize option. (defaults to null)
* @param non-empty-string[]|null $mimeTypes Acceptable media types
Expand Down
Loading
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy