Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

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

Copy link
Copy link
Closed as not planned
@GromNaN

Description

@GromNaN
Issue body actions

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

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.