Skip to content

Commit 218ba02

Browse files
committed
Merge branch '6.3' into 6.4
* 6.3: Rename context flag Update components/serializer.rst Update components/serializer.rst Update components/serializer.rst Update components/serializer.rst Fix broken code example Add feature description
2 parents b6d817d + c0eb95c commit 218ba02

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

components/serializer.rst

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1303,6 +1303,33 @@ to ``true``::
13031303
$result = $normalizer->normalize($dummy, 'json', [AbstractObjectNormalizer::SKIP_NULL_VALUES => true]);
13041304
// ['bar' => 'notNull']
13051305

1306+
Require all Properties
1307+
----------------------
1308+
1309+
By default, the Serializer will add ``null`` to nullable properties when the parameters for those are not provided.
1310+
You can change this behavior by setting the ``AbstractNormalizer::REQUIRE_ALL_PROPERTIES`` context option
1311+
to ``true``::
1312+
1313+
class Dummy
1314+
{
1315+
public function __construct(
1316+
public string $foo,
1317+
public ?string $bar,
1318+
) {
1319+
}
1320+
}
1321+
1322+
$data = ['foo' => 'notNull'];
1323+
1324+
$normalizer = new ObjectNormalizer();
1325+
$result = $normalizer->denormalize($data, Dummy::class, 'json', [AbstractNormalizer::REQUIRE_ALL_PROPERTIES => true]);
1326+
// throws Symfony\Component\Serializer\Exception\MissingConstructorArgumentException
1327+
1328+
.. versionadded:: 6.3
1329+
1330+
The ``AbstractNormalizer::PREVENT_NULLABLE_FALLBACK`` context option
1331+
was introduced in Symfony 6.3.
1332+
13061333
Skipping Uninitialized Properties
13071334
---------------------------------
13081335

0 commit comments

Comments
 (0)