Skip to content

Conversation

@xabbuh
Copy link
Member

@xabbuh xabbuh commented Sep 3, 2025

Q A
Branch? 7.3
Bug fix? yes
New feature? no
Deprecations? no
Issues Fix #61612
License MIT

generalized alternative to #61613

}

if (array_is_list($options)) {
if (array_is_list($options) || isset($options['value'])) {
Copy link
Member Author

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;
}

Copy link
Member Author

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

Copy link
Member

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?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@xabbuh xabbuh changed the title [Validator] fall back to legacy options handling if the value element is used [Validator] fall back to legacy options handling if configured named arguments do not match Sep 4, 2025
@nicolas-grekas
Copy link
Member

Thank you @xabbuh.

@nicolas-grekas nicolas-grekas merged commit e7c41fe into symfony:7.3 Sep 4, 2025
7 of 11 checks passed
@nicolas-grekas
Copy link
Member

nicolas-grekas commented Sep 4, 2025

Thanks! Follow up welcome on 7.4 🙏

@xabbuh
Copy link
Member Author

xabbuh commented Sep 19, 2025

the follow-up PR for the deprecation is here: #61791

nicolas-grekas added a commit that referenced this pull request Sep 24, 2025
… 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
symfony-splitter pushed a commit to symfony/validator that referenced this pull request Sep 24, 2025
… 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
@fabpot fabpot mentioned this pull request Sep 27, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants