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] AddedStrictTypes as class constraint with not nullable typed properties#36494
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
333ca17 to9cf7cbdComparero0NL commentedApr 20, 2020
how can |
HeahDude commentedApr 20, 2020
@ro0NL when hydrating objects from external source/input, e.g a submitted form or a deserialized payload to be validated. |
ro0NL commentedApr 20, 2020
AFAIK you'll hit Perhaps the ship has sailed, and this complements our PHP74 support in general. But IMHO one should validate the raw payload, before hydrating a non-nullable property. |
HeahDude commentedApr 20, 2020
Not in the context of the form given#36492. This allows to decouple model from hydrators, and explicitly declare not nullable props with the type instead of a not null constraint. |
HeahDude commentedApr 20, 2020
Or |
ro0NL commentedApr 20, 2020
does that mean In general i like However, IMHO it's developer concern. De facto, objects shouldnt be in uninitialized state after construct. |
fabpot commentedAug 18, 2020
I'm not sure I like this StrictTypes constraint. What do you think@xabbuh? |
fabpot commentedSep 7, 2020
Closing for now as the PR is stale. Feel free to reopen when you have time. Thank you. |
After I commented#36352 (comment), I started to work on a proper constraint instead. Following#35532,#36492 and#36352, this PR enables the following short example:
Until#36352 is merged or close, only the second commit should be reviewed here.
Side note: unlike
AutoMapping, this feature require PHP 7.4, but do not rely on complexity or other components to achieve a simple non nullable check.This remains explicit and works for simple VO which do not require PHP annotations anymore, nor ORM mapping.