ac70edf8cd
This PR was squashed before being merged into the 3.4 branch (closes #27326).
Discussion
----------
[Serializer] deserialize from xml: Fix a collection that contains the only one element
| Q | A
| ------------- | ---
| Branch? | 3.4
| Bug fix? | yes
| New feature? | no
| BC breaks? | no
| Deprecations? | no
| Tests pass? | yes
| Fixed tickets | #27279
| License | MIT
| Doc PR |
In xml when parent node (`restaurants`) contains several children nodes with the same tag (`restaurant`) it is clear that the children form a collection:
```
restaurants = {array} [1]
restaurant = {array} [2]
0 = {array} [2]
name = "Some restaurant name"
type = "Chinese"
1 = {array} [2]
name = "Another restaurant name"
type = "Italian"
```
Afterwards the object denormalizer has no problem to create a collection of restaurants.
But when there is only one child (`restaurant`) the decoded normalized array will not contain a collection:
```
restaurants = {array} [1]
restaurant = {array} [2]
name = "Some restaurant name"
type = "Chinese"
```
In this situation the object denormalizer threw unexpected exception. This PR modifies `AbstractObjectNormalizer` that is it will fill a collection containing the sole element properly.
Commits
-------
|
||
---|---|---|
.. | ||
AbstractNormalizerTest.php | ||
AbstractObjectNormalizerTest.php | ||
ArrayDenormalizerTest.php | ||
CustomNormalizerTest.php | ||
DataUriNormalizerTest.php | ||
DateIntervalNormalizerTest.php | ||
DateTimeNormalizerTest.php | ||
GetSetMethodNormalizerTest.php | ||
JsonSerializableNormalizerTest.php | ||
ObjectNormalizerTest.php | ||
ObjectToPopulateTraitTest.php | ||
PropertyNormalizerTest.php | ||
TestDenormalizer.php | ||
TestNormalizer.php |