-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
Service constructor arguments validating #39678
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
Service constructor arguments validating #39678
Conversation
Hey! I did a quick review of this PR, I think most things looks good. To help keep things organized, we don't allow "Draft" pull requests. Could you please click the "ready for review" button or close this PR and open a new one when you are done? Note that a pull request does not have to be "perfect" or "ready for merge" when you first open it. We just want it to be ready for a first review. Cheers! Carsonbot |
76ec3b8
to
cbdf2b2
Compare
'$email' => 'test@email.com', | ||
'$datetime' => '2020-12-31 23:59:59', | ||
'$ipAddresses' => ['8.8.4.4', '8.8.8.8'], | ||
'$noConstraints' => 'no constraints for this argument', |
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.
Is this used?
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.
@OskarStark, sorry, didn't understand what do you mean
Hi, thanks for working on this. I'm sorry but I'm 👎 with this approach: this adds complexity and adds some coupling with the validator component. I don't think this code infrastructure is worth the maintenance effort. Another reason is that validating arguments at compile time conflicts with env vars. |
@nicolas-grekas, hi. Thanks for the detailed answer. |
Thanks for your understanding, closing here for now, let's discuss on the issue. |
proof of concept, caused by #31882.
these changes give the possibility to validate services constructor arguments using
Validation
component constraints.validation implemented in
ValidateConstructorArgumentsPass()
and runs withoptimizationPasses
, but could be moved to cli-command likeCheckTypeDeclarationsPass
(#27825).constraints definition example for
.yaml
files,.xml
and.php
files are skipped because the implementation has not been approved yet.