5f91f74f4d
This PR was merged into the 3.4 branch.
Discussion
----------
[Serializer] AbstractObjectNormalizer: Allow to disable type enforcement
| Q | A
| ------------- | ---
| Branch? | 3.4 <!-- see comment below -->
| Bug fix? | no
| New feature? | yes <!-- don't forget updating src/**/CHANGELOG.md files -->
| BC breaks? | no
| Deprecations? | no <!-- don't forget updating UPGRADE-*.md files -->
| Tests pass? | yes (failure unrelated)
| Fixed tickets | N/A <!-- #-prefixed issue number(s), if any -->
| License | MIT
| Doc PR | N/A
This allows to denormalize simple DTOs with public properties using the property-info component and the `ObjectNormalizer`. The raised exception is not really useful in such cases, as it cannot be easily handled gracefully to build a proper violation response (too generic and no real hint on the complete attribute path for instance).
Instead, I use the validator component to validate my DTOs and the properties' types, get a proper violation list, and build a response from it.
I wasn't really inspired for the `DISABLE_TYPE_ENFORCEMENT` name.
Commits
-------
|
||
---|---|---|
.. | ||
Annotation | ||
DependencyInjection | ||
Encoder | ||
Exception | ||
Mapping | ||
NameConverter | ||
Normalizer | ||
Tests | ||
.gitignore | ||
CHANGELOG.md | ||
composer.json | ||
LICENSE | ||
phpunit.xml.dist | ||
README.md | ||
Serializer.php | ||
SerializerAwareInterface.php | ||
SerializerAwareTrait.php | ||
SerializerInterface.php |
Serializer Component
With the Serializer component it's possible to handle serializing data structures, including object graphs, into array structures or other formats like XML and JSON. It can also handle deserializing XML and JSON back to object graphs.