Commit 8096a42
committed
bug symfony#58615 [Validator] [Choice] Fix callback option if not array returned (symfonyaml)
This PR was squashed before being merged into the 5.4 branch.
Discussion
----------
[Validator] [Choice] Fix callback option if not array returned
| Q | A
| ------------- | ---
| Branch? | 5.4
| Bug fix? | yes
| New feature? | no
| Deprecations? | no
| Issues | Fix symfony#58610
| License | MIT
### Issue
When using the Choice validator `callback` option, and the callback method provided does not return an array or iterable, it causes a PHP error.
See all details and how to reproduce it in the issue symfony#58610
### Solution
In this PR
- Add some checks if the callback method provided returns an array or iterable
- Add tests for exception and iterable
________________
**NOTE** : This PR replaces [the old one](symfony#58611) _(I messed up with the branch rebase)_
Commits
-------
02d2769 [Validator] [Choice] Fix callback option if not array returnedFile tree
2 files changed
+21
-0
lines changed- src/Symfony/Component/Validator
- Constraints
- Tests/Constraints
2 files changed
+21
-0
lines changedLines changed: 3 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
55 | 55 | | |
56 | 56 | | |
57 | 57 | | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
58 | 61 | | |
59 | 62 | | |
60 | 63 | | |
| |||
Lines changed: 18 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
39 | 39 | | |
40 | 40 | | |
41 | 41 | | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
42 | 47 | | |
43 | 48 | | |
44 | 49 | | |
| |||
134 | 139 | | |
135 | 140 | | |
136 | 141 | | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
137 | 155 | | |
138 | 156 | | |
139 | 157 | | |
| |||
0 commit comments