-
-
Notifications
You must be signed in to change notification settings - Fork 9.8k
[Validator] fall back to legacy options handling if configured named arguments do not match #61617
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
Conversation
| } | ||
|
|
||
| if (array_is_list($options)) { | ||
| if (array_is_list($options) || isset($options['value'])) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This might be a bit risky if the constraint has a constructor argument named $value.
An alternative solution would be wrapping the call further down in a try catch block like this:
try {
return new $className(...$options);
} catch (\Error $e) {
if (str_starts_with($e->getMessage(), 'Unknown named parameter')) {
return new $className($options);
}
throw $e;
}There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
in any case, we should deprecate this in 7.4 after merging up
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let's do it the safest way?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
|
Thank you @xabbuh. |
|
Thanks! Follow up welcome on 7.4 🙏 |
|
the follow-up PR for the deprecation is here: #61791 |
… in YAML/XML mapping files (xabbuh) This PR was merged into the 7.4 branch. Discussion ---------- [Validator] deprecate implicit constraint option names in YAML/XML mapping files | Q | A | ------------- | --- | Branch? | 7.4 | Bug fix? | no | New feature? | no | Deprecations? | yes | Issues | see #61617 (comment) | License | MIT Commits ------- 14ca8ac deprecate implicit constraint option names in YAML/XML mapping files
… in YAML/XML mapping files (xabbuh) This PR was merged into the 7.4 branch. Discussion ---------- [Validator] deprecate implicit constraint option names in YAML/XML mapping files | Q | A | ------------- | --- | Branch? | 7.4 | Bug fix? | no | New feature? | no | Deprecations? | yes | Issues | see symfony/symfony#61617 (comment) | License | MIT Commits ------- 14ca8ac7dcc deprecate implicit constraint option names in YAML/XML mapping files
generalized alternative to #61613