Skip to content

[Validator] Add missing HasNamedArguments to some constraints #60840

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
Jun 23, 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
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

namespace Symfony\Component\Security\Core\Validator\Constraints;

use Symfony\Component\Validator\Attribute\HasNamedArguments;
use Symfony\Component\Validator\Constraint;

#[\Attribute(\Attribute::TARGET_PROPERTY | \Attribute::TARGET_METHOD | \Attribute::IS_REPEATABLE)]
Expand All @@ -25,6 +26,7 @@ class UserPassword extends Constraint
public string $message = 'This value should be the user\'s current password.';
public string $service = 'security.validator.user_password';

#[HasNamedArguments]
public function __construct(?array $options = null, ?string $message = null, ?string $service = null, ?array $groups = null, mixed $payload = null)
{
parent::__construct($options, $groups, $payload);
Expand Down
2 changes: 2 additions & 0 deletions src/Symfony/Component/Validator/Constraints/AtLeastOneOf.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

namespace Symfony\Component\Validator\Constraints;

use Symfony\Component\Validator\Attribute\HasNamedArguments;
use Symfony\Component\Validator\Constraint;

/**
Expand Down Expand Up @@ -39,6 +40,7 @@ class AtLeastOneOf extends Composite
* @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)
{
if (\is_array($constraints) && !array_is_list($constraints)) {
Expand Down
2 changes: 2 additions & 0 deletions src/Symfony/Component/Validator/Constraints/Composite.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

namespace Symfony\Component\Validator\Constraints;

use Symfony\Component\Validator\Attribute\HasNamedArguments;
use Symfony\Component\Validator\Constraint;
use Symfony\Component\Validator\Exception\ConstraintDefinitionException;

Expand Down Expand Up @@ -49,6 +50,7 @@ abstract class Composite extends Constraint
* cached. When constraints are loaded from the cache, no more group
* checks need to be done.
*/
#[HasNamedArguments]
public function __construct(mixed $options = null, ?array $groups = null, mixed $payload = null)
{
parent::__construct($options, $groups, $payload);
Expand Down
2 changes: 2 additions & 0 deletions src/Symfony/Component/Validator/Constraints/Compound.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

namespace Symfony\Component\Validator\Constraints;

use Symfony\Component\Validator\Attribute\HasNamedArguments;
use Symfony\Component\Validator\Constraint;
use Symfony\Component\Validator\Exception\ConstraintDefinitionException;

Expand All @@ -24,6 +25,7 @@ abstract class Compound extends Composite
/** @var Constraint[] */
public array $constraints = [];

#[HasNamedArguments]
public function __construct(mixed $options = null, ?array $groups = null, mixed $payload = null)
{
if (isset($options[$this->getCompositeOption()])) {
Expand Down
3 changes: 3 additions & 0 deletions src/Symfony/Component/Validator/Constraints/GroupSequence.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@

namespace Symfony\Component\Validator\Constraints;

use Symfony\Component\Validator\Attribute\HasNamedArguments;

/**
* A sequence of validation groups.
*
Expand Down Expand Up @@ -75,6 +77,7 @@ class GroupSequence
*
* @param array<string|string[]|GroupSequence> $groups The groups in the sequence
*/
#[HasNamedArguments]
public function __construct(array $groups)
{
$this->groups = $groups['value'] ?? $groups;
Expand Down
3 changes: 3 additions & 0 deletions src/Symfony/Component/Validator/Constraints/Image.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@

namespace Symfony\Component\Validator\Constraints;

use Symfony\Component\Validator\Attribute\HasNamedArguments;

/**
* Validates that a file (or a path to a file) is a valid image.
*
Expand Down Expand Up @@ -118,6 +120,7 @@ class Image extends File
*
* @see https://www.iana.org/assignments/media-types/media-types.xhtml Existing media types
*/
#[HasNamedArguments]
public function __construct(
?array $options = null,
int|string|null $maxSize = null,
Expand Down
2 changes: 2 additions & 0 deletions src/Symfony/Component/Validator/Constraints/Sequentially.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

namespace Symfony\Component\Validator\Constraints;

use Symfony\Component\Validator\Attribute\HasNamedArguments;
use Symfony\Component\Validator\Constraint;

/**
Expand All @@ -28,6 +29,7 @@ class Sequentially extends Composite
* @param Constraint[]|array<string,mixed>|null $constraints An array of validation constraints
* @param string[]|null $groups
*/
#[HasNamedArguments]
public function __construct(mixed $constraints = null, ?array $groups = null, mixed $payload = null)
{
if (\is_array($constraints) && !array_is_list($constraints)) {
Expand Down
Loading