Skip to content

Commit cebe1f4

Browse files
committed
Merge branch '6.4' into 7.1
* 6.4: [Serializer] Minor improvements
2 parents 5aa1ea2 + 44f0f13 commit cebe1f4

File tree

2 files changed

+13
-6
lines changed

2 files changed

+13
-6
lines changed

serializer.rst

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -956,16 +956,22 @@ parameter::
956956
$jsonData = ...; // the serialized JSON data from the previous example
957957
$persons = $serializer->deserialize($JsonData, Person::class.'[]', 'json');
958958

959-
For nested classes, you have to add a PHPDoc type to the property/setter::
959+
For nested classes, you have to add a PHPDoc type to the property, constructor or setter::
960960

961961
// src/Model/UserGroup.php
962962
namespace App\Model;
963963

964964
class UserGroup
965965
{
966-
private array $members;
966+
/**
967+
* @param Person[] $members
968+
*/
969+
public function __construct(
970+
private array $members,
971+
) {
972+
}
967973

968-
// ...
974+
// or if you're using a setter
969975

970976
/**
971977
* @param Person[] $members
@@ -974,6 +980,8 @@ For nested classes, you have to add a PHPDoc type to the property/setter::
974980
{
975981
$this->members = $members;
976982
}
983+
984+
// ...
977985
}
978986

979987
.. tip::
@@ -1351,8 +1359,6 @@ normalizers (in order of priority):
13511359
During denormalization, it supports using the constructor as well as
13521360
the discovered methods.
13531361

1354-
:ref:`serializer.encoder <reference-dic-tags-serializer-encoder>`
1355-
13561362
.. danger::
13571363

13581364
Always make sure the ``DateTimeNormalizer`` is registered when

serializer/encoders.rst

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -307,7 +307,8 @@ as a service in your app. If you're using the
307307
that's done automatically!
308308

309309
If you're not using :ref:`autoconfigure <services-autoconfigure>`, make sure
310-
to register your class as a service and tag it with ``serializer.encoder``:
310+
to register your class as a service and tag it with
311+
:ref:`serializer.encoder <reference-dic-tags-serializer-encoder>`:
311312

312313
.. configuration-block::
313314

0 commit comments

Comments
 (0)