Skip to content

[Validator] Deprecate passing options as an array in 7.1 #52133

Closed as not planned
@GromNaN

Description

@GromNaN

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.

If developers need to create a constraint attribute from an array, they can use array unpacking.

Example

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions