Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork9.7k
[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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Conversation
xabbuh commentedMay 19, 2020
I think we should also throw a |
nicolas-grekas commentedMay 19, 2020 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
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 && !$constraintOrValidatorinstanceof ValidatorInterface) { | ||
| thrownew \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))); |
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.
The error message should sayor "null" too.
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.
no need to advertise this case IMHO
As spotted by@stof in#31466 (comment)