Commit cfb39c5
committed
bug symfony#58917 [OptionsResolver] Allow Union/Intersection Types in Resolved Closures (zanbaldwin)
This PR was squashed before being merged into the 6.4 branch.
Discussion
----------
[OptionsResolver] Allow Union/Intersection Types in Resolved Closures
| Q | A
| ------------- | ---
| Branch? | 6.4
| Bug fix? | yes
| New feature? | no
| Deprecations? | no
| Issues | _N/A_
| License | MIT
Using intersection/union types in Closures set in OptionsResolver currently causes the fatal error:
`Attempted to call an undefined method named "getName" of class "ReflectionUnionType".`
in `vendor/symfony/options-resolver/OptionsResolver.php` (line 235).
This can be re-created with following form type:
```php
class ExampleType extends AbstractType
{
public function getParent(): string
{
return Type\ChoiceType::class;
}
public function configureOptions(OptionsResolver $resolver): void
{
$resolver->setDefaults([
'data_class' => MyEntity::class,
// Assume MyEntity is Stringable.
'choice_value' => fn (MyEntity|string|null $entity): string => (string) $entity,
]);
}
}
```
Commits
-------
61ddfc4 [OptionsResolver] Allow Union/Intersection Types in Resolved ClosuresFile tree
2 files changed
+23
-1
lines changed- src/Symfony/Component/OptionsResolver
- Tests
2 files changed
+23
-1
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
232 | 232 | | |
233 | 233 | | |
234 | 234 | | |
235 | | - | |
| 235 | + | |
236 | 236 | | |
237 | 237 | | |
238 | 238 | | |
| |||
Lines changed: 22 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
159 | 159 | | |
160 | 160 | | |
161 | 161 | | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
162 | 184 | | |
163 | 185 | | |
164 | 186 | | |
| |||
0 commit comments