This repository has been archived on 2023-08-20. You can view files and clone it, but cannot push or open issues or pull requests.
symfony/src/Symfony/Component/Serializer/Tests/Normalizer
Fabien Potencier ac70edf8cd bug #27326 [Serializer] deserialize from xml: Fix a collection that contains the only one element (webnet-fr)
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
-------

1f346f446d [Serializer] deserialize from xml: Fix a collection that contains the only one element
2018-06-10 11:53:47 +02:00
..
AbstractNormalizerTest.php [Serializer] Fix serializer tries to denormalize null values on nullable properties 2018-05-26 11:53:53 +02:00
AbstractObjectNormalizerTest.php [Serializer] deserialize from xml: Fix a collection that contains the only one element 2018-06-10 11:53:40 +02:00
ArrayDenormalizerTest.php Updated PHPUnit namespaces 2017-02-20 13:35:43 +01:00
CustomNormalizerTest.php [Serializer] Add Support for in CustomNormalizer 2017-09-27 10:32:12 -07:00
DataUriNormalizerTest.php Updated PHPUnit namespaces 2017-02-20 14:34:33 +01:00
DateIntervalNormalizerTest.php [Serializer][FrameworkBundle] Add a DateInterval normalizer 2017-09-15 18:08:37 +02:00
DateTimeNormalizerTest.php Merge branch '3.3' into 3.4 2018-01-18 23:16:57 +01:00
GetSetMethodNormalizerTest.php [Component][Serializer][Normalizer] : Deal it with Has Method for the Normalizer/Denormalizer 2017-07-05 15:47:26 -04:00
JsonSerializableNormalizerTest.php Updated PHPUnit namespaces 2017-02-20 14:34:33 +01:00
ObjectNormalizerTest.php Merge branch '3.3' into 3.4 2017-12-08 16:24:53 +01:00
ObjectToPopulateTraitTest.php [Serializer] Add Support for in CustomNormalizer 2017-09-27 10:32:12 -07:00
PropertyNormalizerTest.php fixing that PropertyNormalizer supports parent properties 2017-11-20 17:26:54 +01:00
TestDenormalizer.php fix phpdoc's alignment 2014-12-07 19:24:30 +01:00
TestNormalizer.php fix phpdoc's alignment 2014-12-07 19:24:30 +01:00