Commit 1a60616
committed
bug symfony#61746 [Serializer] Fix unknown type in denormalization errors when union type used in constructor (d-mitrofanov-v)
This PR was merged into the 6.4 branch.
Discussion
----------
[Serializer] Fix unknown type in denormalization errors when union type used in constructor
| Q | A
| ------------- | ---
| Branch? | 6.4
| Bug fix? | yes
| New feature? | no <!-- if yes, also update src/**/CHANGELOG.md -->
| Deprecations? | no <!-- if yes, also update UPGRADE-*.md and src/**/CHANGELOG.md -->
| Issues | Fix - <!-- prefix each issue number with "Fix #"; no need to create an issue if none exists, explain below -->
| License | MIT
Fixes getting "unknown" in `expectedTypes` of `NotNormalizableValueException` if constructor properties have union types and if this property is absent from json. This also fixes getting error "This value should be of type unknown" when building text for `PartialDenormalizationException` in `RequestPayloadValueResolver`. The resulting string will be "This value should be of type int|float".
The only problem that i see is that `ReflectionUnionType::getTypes()` returns types in its own order which might not be the same as the order in constructor. For example, even if we have `float|int` in constructor, `ReflectionUnionType::getTypes()` will return types in `int, float` order. But it seems that getting types in a different order is still better then getting "unknown"
Commits
-------
eb8f941 [Serializer] Fix unknown type in denormalization errors when union type used in constructorFile tree
3 files changed
+89
-4
lines changed- src/Symfony/Component/Serializer
- Normalizer
- Tests
- Fixtures
3 files changed
+89
-4
lines changedLines changed: 10 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
408 | 408 | | |
409 | 409 | | |
410 | 410 | | |
411 | | - | |
| 411 | + | |
412 | 412 | | |
413 | | - | |
414 | | - | |
| 413 | + | |
| 414 | + | |
| 415 | + | |
| 416 | + | |
| 417 | + | |
| 418 | + | |
| 419 | + | |
| 420 | + | |
415 | 421 | | |
416 | 422 | | |
417 | 423 | | |
418 | 424 | | |
419 | 425 | | |
420 | | - | |
| 426 | + | |
421 | 427 | | |
422 | 428 | | |
423 | 429 | | |
| |||
Lines changed: 24 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
Lines changed: 55 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
62 | 62 | | |
63 | 63 | | |
64 | 64 | | |
| 65 | + | |
65 | 66 | | |
66 | 67 | | |
67 | 68 | | |
| |||
1392 | 1393 | | |
1393 | 1394 | | |
1394 | 1395 | | |
| 1396 | + | |
| 1397 | + | |
| 1398 | + | |
| 1399 | + | |
| 1400 | + | |
| 1401 | + | |
| 1402 | + | |
| 1403 | + | |
| 1404 | + | |
| 1405 | + | |
| 1406 | + | |
| 1407 | + | |
| 1408 | + | |
| 1409 | + | |
| 1410 | + | |
| 1411 | + | |
| 1412 | + | |
| 1413 | + | |
| 1414 | + | |
| 1415 | + | |
| 1416 | + | |
| 1417 | + | |
| 1418 | + | |
| 1419 | + | |
| 1420 | + | |
| 1421 | + | |
| 1422 | + | |
| 1423 | + | |
| 1424 | + | |
| 1425 | + | |
| 1426 | + | |
| 1427 | + | |
| 1428 | + | |
| 1429 | + | |
| 1430 | + | |
| 1431 | + | |
| 1432 | + | |
| 1433 | + | |
| 1434 | + | |
| 1435 | + | |
| 1436 | + | |
| 1437 | + | |
| 1438 | + | |
| 1439 | + | |
| 1440 | + | |
| 1441 | + | |
| 1442 | + | |
| 1443 | + | |
| 1444 | + | |
| 1445 | + | |
| 1446 | + | |
| 1447 | + | |
| 1448 | + | |
| 1449 | + | |
1395 | 1450 | | |
1396 | 1451 | | |
1397 | 1452 | | |
| |||
0 commit comments