From 5c94785bd70ac2ad751ba137bc5c3286219e3b35 Mon Sep 17 00:00:00 2001 From: Hidde Wieringa Date: Sat, 14 Oct 2017 16:08:26 +0200 Subject: [PATCH] Added option to disable type enforcement in serializer --- components/serializer.rst | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/components/serializer.rst b/components/serializer.rst index 2b7ea47f05a..d9011365a8a 100644 --- a/components/serializer.rst +++ b/components/serializer.rst @@ -877,7 +877,7 @@ parameter of the ``ObjectNormalizer``:: public $bar; } - $normalizer = new ObjectNormalizer(null, null, null, new ReflectionExtractor()); // + $normalizer = new ObjectNormalizer(null, null, null, new ReflectionExtractor()); $serializer = new Serializer(array(new DateTimeNormalizer(), $normalizer)); $obj = $serializer->denormalize( @@ -892,7 +892,9 @@ parameter of the ``ObjectNormalizer``:: When a ``PropertyTypeExtractor`` is available, the normalizer will also check that the data to denormalize matches the type of the property (even for primitive types). For instance, if a ``string`` is provided, but the type of the property is ``int``, an :class:`Symfony\\Component\\Serializer\\Exception\\UnexpectedValueException` -will be thrown. +will be thrown. The type enforcement of the properties can be disabled by setting +the serializer context option ``ObjectNormalizer::DISABLE_TYPE_ENFORCEMENT`` +to ``true``. Learn more ----------