Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 11 additions & 5 deletions serializer.rst
Original file line number Diff line number Diff line change
Expand Up @@ -958,16 +958,22 @@ parameter::
$jsonData = ...; // the serialized JSON data from the previous example
$persons = $serializer->deserialize($JsonData, Person::class.'[]', 'json');

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

// src/Model/UserGroup.php
namespace App\Model;

class UserGroup
{
private array $members;
/**
* @param Person[] $members
*/
public function __construct(
private array $members,
) {
}

// ...
// or if you're using a setter

/**
* @param Person[] $members
Expand All @@ -976,6 +982,8 @@ For nested classes, you have to add a PHPDoc type to the property/setter::
{
$this->members = $members;
}

// ...
}

.. tip::
Expand Down Expand Up @@ -1357,8 +1365,6 @@ normalizers (in order of priority):
During denormalization, it supports using the constructor as well as
the discovered methods.

:ref:`serializer.encoder <reference-dic-tags-serializer-encoder>`

.. danger::

Always make sure the ``DateTimeNormalizer`` is registered when
Expand Down
3 changes: 2 additions & 1 deletion serializer/encoders.rst
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,8 @@ as a service in your app. If you're using the
that's done automatically!

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

.. configuration-block::

Expand Down
Loading