-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[Validator] Ensure a group is set on a constraint (fix BC break) #44847
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
lyrixx
commented
Dec 29, 2021
Q | A |
---|---|
Branch? | 4.4 |
Bug fix? | yes |
New feature? | no |
Deprecations? | no |
Tickets | Fix #44846 |
License | MIT |
Doc PR |
Are you calling the constructor? Because if not, that's the issue. The property is supposed to be lazily initialized (that's why it's unset in the constructor) |
No I don't. It used to work in previous version of symfony. And nothing force us to call the constructor (like it can be done in Command class). So to me it's a BC break and this PR solves this issue |
This change is going to break Composite constraints, see symfony/src/Symfony/Component/Validator/Constraints/Composite.php Lines 82 to 96 in 4274a1f
I understand this worked before because the property was undeclared. But to adapt to PHP 8.2, we have to declare all properties. Any other idea? |
Instead, can't we check that the property is null, meaning it need to be unset and __get again before being usable? |
Also, I suggest trigger a deprecation saying that the parent constructor must be called. |
how would you do that? with a check in all public method? |
What about #44854 instead? |
…en called (nicolas-grekas) This PR was merged into the 4.4 branch. Discussion ---------- [Validator] throw when Constraint::_construct() has not been called | Q | A | ------------- | --- | Branch? | 4.4 | Bug fix? | yes | New feature? | no | Deprecations? | no | Tickets | Fix #44846 | License | MIT | Doc PR | - Instead of #44847 Commits ------- 20aacce [Validator] throw when Constraint::_construct() has not been called
Superseded by #44854 |