-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[Validator] Type Properties not working in Constraints #37387
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
Labels
Comments
I've actually tried to use the Reflection API to fix this but it didn't help...
|
see #37392 |
fabpot
added a commit
that referenced
this issue
Jun 25, 2020
…tions (xabbuh) This PR was merged into the 3.4 branch. Discussion ---------- [Validator] fix handling typed properties as constraint options | Q | A | ------------- | --- | Branch? | 3.4 | Bug fix? | yes | New feature? | no | Deprecations? | no | Tickets | Fix #37387 | License | MIT | Doc PR | Commits ------- 4a66a60 fix handling typed properties as constraint options
@fabpot this also need to go into all newer versions after 3.4, what's the process? thanks |
@nico-incubiq Branches are regularly merged up into all other maintained branches. |
Great, thank you |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Symfony version(s) affected: 5.1.2 (and others too, as long as you're using PHP 7.4 and typed properties)
Description
PHP 7.4 introduced typed properties, which seem to be the way forward to build type-safe applications. But due to the way the Constraint component works to validate its options, it is not possible to use typed properties in a Constraint.
How to reproduce
Possible Solution
The issue is due to the Constraint class using
get_object_vars($this)
in its constructor to find all the available properties on the class, which won't return the uninitialised ones, as explained here https://bugs.php.net/bug.php?id=78954. One solution is to use Reflection to find out what properties are available.The text was updated successfully, but these errors were encountered: