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] allow passing a validator to Validation::createCallable() #36859

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

Merged
merged 1 commit into from
May 19, 2020

Conversation

nicolas-grekas
Copy link
Member

Q A
Branch? 5.1
Bug fix? yes
New feature? no
Deprecations? no
Tickets -
License MIT
Doc PR -

As spotted by @stof in #31466 (comment)

@xabbuh
Copy link
Member

xabbuh commented May 19, 2020

I think we should also throw a TypeError if one calls the method with null as the first argument followed by some constraints.

@nicolas-grekas
Copy link
Member Author

nicolas-grekas commented May 19, 2020

If we don't allow null, it means the signature cannot be expressed using regular PHP types and we must trick it using func_num_args(). I think we'd better avoid such things.

$constraints = \func_get_args();
$validator = null;
} elseif (null !== $constraintOrValidator && !$constraintOrValidator instanceof ValidatorInterface) {
throw new \TypeError(sprintf('Argument 1 passed to "%s()" must be a "%s" or a "%s" object, "%s" given.', __METHOD__, Constraint::class, ValidatorInterface::class, get_debug_type($constraintOrValidator)));
Copy link
Member

Choose a reason for hiding this comment

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

The error message should say or "null" too.

Copy link
Member Author

Choose a reason for hiding this comment

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

no need to advertise this case IMHO

@nicolas-grekas nicolas-grekas merged commit 0fd5b95 into symfony:5.1 May 19, 2020
@nicolas-grekas nicolas-grekas deleted the v-cb branch May 26, 2020 06:59
@fabpot fabpot mentioned this pull request May 26, 2020
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.

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