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] Fix using known option names as field names#53133
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
Uh oh!
There was an error while loading.Please reload this page.
| $knowOptions =array_map(function (\ReflectionParameter$parameter) { | ||
| return$parameter->name; | ||
| }, (new \ReflectionMethod(__METHOD__))->getParameters()); |
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.
| $knowOptions = array_map(function (\ReflectionParameter$parameter) { | |
| return$parameter->name; | |
| }, (new \ReflectionMethod(__METHOD__))->getParameters()); | |
| static$knowOptions; | |
| $knownOptions ??=array_column((new \ReflectionMethod(__METHOD__))->getParameters(),'name'); |
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.
Done, I had to adjust the code for PHP 7.2. I'm wondering, is the static variable necessary since this all happens in the constructor?
e92d8a1 to51d1960Compare51d1960 to51ec528Comparefabpot commentedDec 24, 2023
Thank you@HypeMC. |
tscni commentedJan 2, 2024
Fyi, this breaks code where |
xabbuh commentedJan 3, 2024
This PR was merged into the 5.4 branch.Discussion----------[Validator] re-allow an empty list of fields| Q | A| ------------- | ---| Branch? | 5.4| Bug fix? | yes| New feature? | no| Deprecations? | no| Issues |Fix#53133 (comment)| License | MITCommits-------098c14c re-allow an empty list of fields
This PR was merged into the 5.4 branch.Discussion----------[Validator] re-allow an empty list of fields| Q | A| ------------- | ---| Branch? | 5.4| Bug fix? | yes| New feature? | no| Deprecations? | no| Issues |Fixsymfony/symfony#53133 (comment)| License | MITCommits-------098c14cc92 re-allow an empty list of fields
dresslerdemos commentedJan 5, 2024 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
I tried this (#53383) fix and it still breaks for an empty list of constraints, which I confirmed was working in For my use case I can mitigate this by using |
nerones commentedJan 5, 2024
just had the same problem as@dresslerdemos |
xabbuh commentedJan 5, 2024
I have a fix pending locally. I’ll keep you posted. |
xabbuh commentedJan 6, 2024
@dresslerdemos@nerones Can you check if#53443 fixes it for you? |
… (xabbuh, HypeMC)This PR was merged into the 5.4 branch.Discussion----------[Validator] Fix fields without constraints in `Collection`| Q | A| ------------- | ---| Branch? | 5.4| Bug fix? | yes| New feature? | no| Deprecations? | no| Issues |Fix#53133 (comment),Fix#53455| License | MITContinuation of#53443.Commits-------f6217d8 [Validator] Fix fields without constraints in `Collection`b341535 deal with fields for which no constraints have been configured
… (xabbuh, HypeMC)This PR was merged into the 5.4 branch.Discussion----------[Validator] Fix fields without constraints in `Collection`| Q | A| ------------- | ---| Branch? | 5.4| Bug fix? | yes| New feature? | no| Deprecations? | no| Issues |Fixsymfony/symfony#53133 (comment), Fix #53455| License | MITContinuation of #53443.Commits-------f6217d87e6 [Validator] Fix fields without constraints in `Collection`b341535558 deal with fields for which no constraints have been configured
Instead of assuming
$fieldsis not the fields array when any of the keys is a known option, let's assume it is the fields array if all keys are known options. Of course, this approach won't work if someone names all their fields after known options, but I don't believe that will actually happen.