8000 [#6975] some minor tweaks · symfony/symfony-docs@3467fc1 · GitHub
[go: up one dir, main page]

Skip to content

Commit 3467fc1

Browse files
committed
[#6975] some minor tweaks
1 parent f156216 commit 3467fc1

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

components/serializer.rst

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -152,12 +152,14 @@ needs three parameters:
152152
#. The name of the class this information will be decoded to
153153
#. The encoder used to convert that information into an array
154154

155-
By default, additional attributes that are not mapped to the denormalized object will be ignored
156-
by the Serializer component. Set the ``allow_extra_attributes`` key of the deserialization context to ``false``
157-
to let the serializer throw an exception when additional attributes are passed.
155+
.. versionadded:: 3.3
156+
Support for the ``allow_extra_attributes`` key in the context was introduced
157+
in Symfony 3.3.
158158

159-
This will throw an :class:`Symfony\\Component\\Serializer\\Exception\\ExtraAttributesException` exception,
160-
because city is not an attribute of the ``Person`` class::
159+
By default, additional attributes that are not mapped to the denormalized
160+
object will be ignored by the Serializer component. Set the ``allow_extra_attributes``
161+
key of the deserialization context to ``false`` to let the serializer throw
162+
an exception when additional attributes are passed::
161163

162164
$data = <<<EOF
163165
<person>
@@ -167,6 +169,8 @@ because city is not an attribute of the ``Person`` class::
167169
</person>
168170
EOF;
169171

172+
// this will throw a Symfony\Component\Serializer\Exception\ExtraAttributesException
173+
// because "city" is not an attribute of the Person class
170174
$person = $serializer->deserialize($data, 'Acme\Person', 'xml', array(
171175
'allow_extra_attributes' => false,
172176
));

0 commit comments

Comments
 (0)
0