File tree Expand file tree Collapse file tree 1 file changed +9
-5
lines changed Expand file tree Collapse file tree 1 file changed +9
-5
lines changed Original file line number Diff line number Diff line change @@ -152,12 +152,14 @@ needs three parameters:
152
152
#. The name of the class this information will be decoded to
153
153
#. The encoder used to convert that information into an array
154
154
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 .
158
158
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::
161
163
162
164
$data = <<<EOF
163
165
<person>
@@ -167,6 +169,8 @@ because city is not an attribute of the ``Person`` class::
167
169
</person>
168
170
EOF;
169
171
172
+ // this will throw a Symfony\Component\Serializer\Exception\ExtraAttributesException
173
+ // because "city" is not an attribute of the Person class
170
174
$person = $serializer->deserialize($data, 'Acme\Person', 'xml', array(
171
175
'allow_extra_attributes' => false,
172
176
));
You can’t perform that action at this time.
0 commit comments