Closed as not planned
Description
Description
All the validation constraint attributes have a double signature inherited from Doctrine annotation. You can pass options as an array as first argument or as named arguments.
We promote using named arguments like this:
#[Bic(iban: 'FR14 2004 1010 0505 0001 3M02 606', ibanMessage: 'Constraint Message')]
private $bic1;
The same contraint definition with an array of options should be deprecated.
#[Bic(['iban' => 'FR14 2004 1010 0505 0001 3M02 606', 'ibanMessage' => 'Constraint Message'])]
private $bic1;
This will provide better type definition, especially for required arguments.
@param
doc will become more clear in [Validator] Add PHPDoc to validator constraints #52012.- The attribute
#[HasNamedArguments]
attribute introduced in [Validator] Allow creating constraints with required arguments #45072 will no longer be necessary since all constraint attribute would have named arguments. - Some complex logic to handle arguments would go away.
symfony/src/Symfony/Component/Validator/Constraints/Count.php
Lines 64 to 68 in dc23c8e
If developers need to create a constraint attribute from an array, they can use array unpacking.
Example
No response