Skip to content

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

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

Closed
GromNaN opened this issue Oct 18, 2023 · 2 comments
Closed

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

GromNaN opened this issue Oct 18, 2023 · 2 comments

Comments

@GromNaN
Copy link
Member

GromNaN commented Oct 18, 2023

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

@GromNaN GromNaN added this to the 7.1 milestone Oct 18, 2023
@derrabus
Copy link
Member

Duplicate of #51393.

@derrabus derrabus closed this as not planned Won't fix, can't repro, duplicate, stale Oct 18, 2023
@derrabus derrabus removed this from the 7.1 milestone Oct 18, 2023
@GromNaN
Copy link
Member Author

GromNaN commented Oct 18, 2023

Oh thanks. Didn't see it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants