Skip to content

Commit f6f0755

Browse files
committed
Minor tweaks
1 parent 1fc575c commit f6f0755

File tree

1 file changed

+15
-9
lines changed

1 file changed

+15
-9
lines changed

components/serializer.rst

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1273,17 +1273,19 @@ to ``true``::
12731273
$result = $normalizer->normalize($dummy, 'json', [AbstractObjectNormalizer::SKIP_NULL_VALUES => true]);
12741274
// ['bar' => 'notNull']
12751275

1276-
Skipping uninitialized properties
1276+
Skipping Uninitialized Properties
12771277
---------------------------------
12781278

1279-
PHP 7.4 introduced typed properties, which have a new state - ``uninitialized``.
1280-
This is different from the default ``null`` of untyped properties.
1281-
When you try to access it before giving it an explicit value - you get an error.
1279+
In PHP, typed properties have an ``uninitialized`` state which is different
1280+
from the default ``null`` of untyped properties. When you try to access a typed
1281+
property before giving it an explicit value, you get an error.
12821282

1283-
By default, to avoid the Serializer throwing an error when serializing or normalizing an object with
1284-
uninitialized properties, object normalizer catches these errors and ignores such properties.
1283+
To avoid the Serializer throwing an error when serializing or normalizing an
1284+
object with uninitialized properties, by default the object normalizer catches
1285+
these errors and ignores such properties.
12851286

1286-
You can disable this behavior by setting the ``AbstractObjectNormalizer::SKIP_UNINITIALIZED_VALUES`` context option to ``false``::
1287+
You can disable this behavior by setting the ``AbstractObjectNormalizer::SKIP_UNINITIALIZED_VALUES``
1288+
context option to ``false``::
12871289

12881290
class Dummy {
12891291
public string $foo = 'initialized';
@@ -1296,11 +1298,15 @@ You can disable this behavior by setting the ``AbstractObjectNormalizer::SKIP_UN
12961298

12971299
.. note::
12981300

1299-
Calling ``PropertyNormalizer::normalize`` or ``GetSetMethodNormalizer::normalize`` with ``AbstractObjectNormalizer::SKIP_UNINITIALIZED_VALUES`` context option set to ``false`` will throw an ``\Error`` instance if the given object has uninitialized properties as the normalizer cannot read them (directly or via getter/isser methods).
1301+
Calling ``PropertyNormalizer::normalize`` or ``GetSetMethodNormalizer::normalize``
1302+
with ``AbstractObjectNormalizer::SKIP_UNINITIALIZED_VALUES`` context option set
1303+
to ``false`` will throw an ``\Error`` instance if the given object has uninitialized
1304+
properties as the normalizer cannot read them (directly or via getter/isser methods).
13001305

13011306
.. versionadded:: 5.4
13021307

1303-
The ``AbstractObjectNormalizer::SKIP_UNINITIALIZED_VALUES`` constant was introduced in Symfony 5.4.
1308+
The ``AbstractObjectNormalizer::SKIP_UNINITIALIZED_VALUES`` constant was
1309+
introduced in Symfony 5.4.
13041310

13051311
.. _component-serializer-handling-circular-references:
13061312

0 commit comments

Comments
 (0)