symfony/symfony — pull request #9708 by mnapoli (2013-12-05 17:23:44+00:00)
Title: [Serializer] PropertyNormalizer: a new normalizer that maps an object's properties to an array

| Q | A
| ------------- | ---
| Bug fix? | no
| New feature? | yes
| BC breaks? | no
| Deprecations? | no
| Tests pass? | ? (Serializer tests OK, but not all. master didn't pass locally too, waiting for travis)
| Fixed tickets |
| License | MIT
| Doc PR | if PR is deemed mergeable, I'll write the docs

This PR adds a new Normalizer for the Serializer component: **`PropertyNormalizer`**.

Currently the only normalizer is `GetSetMethodNormalizer`, which calls getters and setters. This new serializer uses the properties values directly.

This is especially useful if you write a webservice and take/return very simple DTO (Data Transfer Objects) which role is only to act like a "named" `stdClass`. Every property is public (the class doesn't contain any logic), and mapping that to an array is pretty easy.

This normalizer takes into account public, but also *private* and *protected* properties.

FYI I've based most of the code of `GetSetMethodNormalizer`.