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
Nicolas Grekas 5f91f74f4d feature #23404 [Serializer] AbstractObjectNormalizer: Allow to disable type enforcement (ogizanagi)
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
-------

959ac2a [Serializer] AbstractObjectNormalizer: Allow to disable type enforcement
2017-07-12 16:21:35 +02:00
..
Annotation Merge branch '3.2' 2016-12-17 11:47:22 +01:00
DependencyInjection [FrameworkBundle][Serializer] Move SerializerPass to the Serializer 2017-01-25 13:54:53 +01:00
Encoder XML Encoder Optional Type Cast 2017-06-16 11:28:02 -07:00
Exception throw exception when extra attributes are used during an object denormalization 2016-09-22 01:36:40 +02:00
Mapping deprecate implicit string casting of mapping keys 2017-03-06 20:18:14 +01:00
NameConverter minor #21676 [Serializer] Reduce complexity of NameConverter (gadelat) 2017-02-20 09:20:53 -08:00
Normalizer feature #23404 [Serializer] AbstractObjectNormalizer: Allow to disable type enforcement (ogizanagi) 2017-07-12 16:21:35 +02:00
Tests feature #23404 [Serializer] AbstractObjectNormalizer: Allow to disable type enforcement (ogizanagi) 2017-07-12 16:21:35 +02:00
.gitignore Added missing files .gitignore 2013-07-21 14:12:18 +02:00
CHANGELOG.md [Serializer] AbstractObjectNormalizer: Allow to disable type enforcement 2017-07-05 11:31:02 +02:00
composer.json [3.4] Allow 4.* deps 2017-05-24 11:02:43 +02:00
LICENSE updated LICENSE year 2017-01-02 12:30:00 -08:00
phpunit.xml.dist fail when detecting risky tests 2017-04-12 09:39:27 +02:00
README.md Updated all the README files 2016-03-04 08:12:06 +01:00
Serializer.php [master] Fix issues reported by static analyse 2017-02-28 16:38:18 +01:00
SerializerAwareInterface.php [2.3] CS And DocBlock Fixes 2014-12-22 16:58:09 +01:00
SerializerAwareTrait.php Add normalizer / denormalizer awarness 2016-02-19 11:48:56 +01:00
SerializerInterface.php @throws annotations should go after @return 2016-06-06 13:03:51 +02:00

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.

Resources