-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[Validator] Added StrictTypes
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
… typed properties
333ca17
to
9cf7cbd
Compare
how can |
@ro0NL when hydrating objects from external source/input, e.g a submitted form or a deserialized payload to be validated. |
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. |
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. |
Or |
does that mean In general i like However, IMHO it's developer concern. De facto, objects shouldnt be in uninitialized state after construct. |
I'm not sure I like this StrictTypes constraint. What do you think @xabbuh? |
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.