Skip to content

Commit d077bce

Browse files
committed
minor #14335 [Serializer] Remove duplicate normalizers docs (HypeMC)
This PR was merged into the 4.4 branch. Discussion ---------- [Serializer] Remove duplicate normalizers docs Currently normalizers are documented in three separate places, each of which contains some information the other two don't. This makes browsing the docs difficult and confusing. With this PR I've consolidated everything to `components/serializer.rst`. I've removed the list from `serializer/normalizers.rst` and added a link to `components/serializer.rst` instead. Since not all normalizers are enabled by the Framework Bundle by default, `serializer.rst` still contains a list of those that are, but the descriptions have been removed and additional links to `components/serializer.rst` added. Commits ------- d76fe1d Remove duplicate normalizers docs
2 parents 37b7ac3 + d76fe1d commit d077bce

File tree

4 files changed

+26
-59
lines changed

4 files changed

+26
-59
lines changed

components/serializer.rst

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -738,7 +738,8 @@ The Serializer component provides several built-in normalizers:
738738
:class:`Symfony\\Component\\Serializer\\Normalizer\\PropertyNormalizer`
739739
This normalizer directly reads and writes public properties as well as
740740
**private and protected** properties (from both the class and all of its
741-
parent classes). It supports calling the constructor during the denormalization process.
741+
parent classes) by using `PHP reflection`_. It supports calling the constructor
742+
during the denormalization process.
742743

743744
Objects are normalized to a map of property names to property values.
744745

@@ -769,7 +770,7 @@ The Serializer component provides several built-in normalizers:
769770
The ``DateTimeZoneNormalizer`` was introduced in Symfony 4.3.
770771

771772
:class:`Symfony\\Component\\Serializer\\Normalizer\\DataUriNormalizer`
772-
This normalizer converts :phpclass:`SplFileInfo` objects into a data URI
773+
This normalizer converts :phpclass:`SplFileInfo` objects into a `data URI`_
773774
string (``data:...``) such that files can be embedded into serialized data.
774775

775776
:class:`Symfony\\Component\\Serializer\\Normalizer\\DateIntervalNormalizer`
@@ -781,9 +782,17 @@ The Serializer component provides several built-in normalizers:
781782
:class:`Symfony\\Component\\Validator\\ConstraintViolationListInterface`
782783
into a list of errors according to the `RFC 7807`_ standard.
783784

785+
.. versionadded:: 4.1
786+
787+
The ``ConstraintViolationListNormalizer`` was introduced in Symfony 4.1.
788+
784789
:class:`Symfony\\Component\\Serializer\\Normalizer\\ProblemNormalizer`
785790
Normalizes errors according to the API Problem spec `RFC 7807`_.
786791

792+
.. versionadded:: 4.4
793+
794+
The ``ProblemNormalizer`` was introduced in Symfony 4.4.
795+
787796
:class:`Symfony\\Component\\Serializer\\Normalizer\\CustomNormalizer`
788797
Normalizes a PHP object using an object that implements :class:`Symfony\\Component\\Serializer\\Normalizer\\NormalizableInterface`.
789798

@@ -1601,3 +1610,5 @@ Learn more
16011610
.. _`Value Objects`: https://en.wikipedia.org/wiki/Value_object
16021611
.. _`API Platform`: https://api-platform.com
16031612
.. _`list of PHP timezones`: https://www.php.net/manual/en/timezones.php
1613+
.. _`PHP reflection`: https://php.net/manual/en/book.reflection.php
1614+
.. _`data URI`: https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/Data_URIs

serializer.rst

Lines changed: 10 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -57,36 +57,18 @@ Encoders supporting the following formats are enabled:
5757

5858
As well as the following normalizers:
5959

60-
* :class:`Symfony\\Component\\Serializer\\Normalizer\\ObjectNormalizer` to
61-
handle typical data objects
62-
* :class:`Symfony\\Component\\Serializer\\Normalizer\\DateTimeNormalizer` for
63-
objects implementing the :phpclass:`DateTimeInterface` interface
64-
* :class:`Symfony\\Component\\Serializer\\Normalizer\\DateTimeZoneNormalizer` for
65-
:phpclass:`DateTimeZone` objects
60+
* :class:`Symfony\\Component\\Serializer\\Normalizer\\ObjectNormalizer`
61+
* :class:`Symfony\\Component\\Serializer\\Normalizer\\DateTimeNormalizer`
62+
* :class:`Symfony\\Component\\Serializer\\Normalizer\\DateTimeZoneNormalizer`
6663
* :class:`Symfony\\Component\\Serializer\\Normalizer\\DateIntervalNormalizer`
67-
for :phpclass:`DateInterval` objects
68-
* :class:`Symfony\\Component\\Serializer\\Normalizer\\DataUriNormalizer` to
69-
transform :phpclass:`SplFileInfo` objects in `Data URIs`_
64+
* :class:`Symfony\\Component\\Serializer\\Normalizer\\DataUriNormalizer`
7065
* :class:`Symfony\\Component\\Serializer\\Normalizer\\JsonSerializableNormalizer`
71-
to deal with objects implementing the :phpclass:`JsonSerializable` interface
72-
* :class:`Symfony\\Component\\Serializer\\Normalizer\\ArrayDenormalizer` to
73-
denormalize arrays of objects using a format like `MyObject[]` (note the `[]` suffix)
74-
* :class:`Symfony\\Component\\Serializer\\Normalizer\\ConstraintViolationListNormalizer` for objects implementing the :class:`Symfony\\Component\\Validator\\ConstraintViolationListInterface` interface
75-
* :class:`Symfony\\Component\\Serializer\\Normalizer\\ProblemNormalizer` for :class:`Symfony\\Component\\ErrorHandler\\Exception\\FlattenException` objects
66+
* :class:`Symfony\\Component\\Serializer\\Normalizer\\ArrayDenormalizer`
67+
* :class:`Symfony\\Component\\Serializer\\Normalizer\\ConstraintViolationListNormalizer`
68+
* :class:`Symfony\\Component\\Serializer\\Normalizer\\ProblemNormalizer`
7669

77-
.. versionadded:: 4.1
78-
79-
The ``ConstraintViolationListNormalizer`` was introduced in Symfony 4.1.
80-
81-
.. versionadded:: 4.3
82-
83-
The ``DateTimeZoneNormalizer`` was introduced in Symfony 4.3.
84-
85-
.. versionadded:: 4.4
86-
87-
The ``ProblemNormalizer`` was introduced in Symfony 4.4.
88-
89-
Custom normalizers and/or encoders can also be loaded by tagging them as
70+
Other :ref:`built-in normalizers <component-serializer-normalizers>` and
71+
custom normalizers and/or encoders can also be loaded by tagging them as
9072
:ref:`serializer.normalizer <reference-dic-tags-serializer-normalizer>` and
9173
:ref:`serializer.encoder <reference-dic-tags-serializer-encoder>`. It's also
9274
possible to set the priority of the tag in order to decide the matching order.
@@ -97,7 +79,7 @@ possible to set the priority of the tag in order to decide the matching order.
9779
``DateTime`` or ``DateTimeImmutable`` classes to avoid excessive memory
9880
usage and exposing internal details.
9981

100-
Here is an example on how to load the
82+
Here is an example on how to load the built-in
10183
:class:`Symfony\\Component\\Serializer\\Normalizer\\GetSetMethodNormalizer`, a
10284
faster alternative to the `ObjectNormalizer` when data objects always use
10385
getters (``getXxx()``), issers (``isXxx()``) or hassers (``hasXxx()``) to read
@@ -298,4 +280,3 @@ take a look at how this bundle works.
298280
.. _`GraphQL`: https://graphql.org
299281
.. _`JSON:API`: https://jsonapi.org
300282
.. _`HAL`: http://stateless.co/hal_specification.html
301-
.. _`Data URIs`: https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/Data_URIs

serializer/custom_normalizer.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ How to Create your Custom Normalizer
66

77
The :doc:`Serializer component </components/serializer>` uses
88
normalizers to transform any data into an array. The component provides several
9-
:doc:`built-in normalizers </serializer/normalizers>` but you may need to create
9+
:ref:`built-in normalizers <component-serializer-normalizers>` but you may need to create
1010
your own normalizer to transform an unsupported data structure.
1111

1212
Creating a New Normalizer

serializer/normalizers.rst

Lines changed: 2 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -21,30 +21,5 @@ Normalizers are enabled in the serializer passing them as its first argument::
2121
Built-in Normalizers
2222
--------------------
2323

24-
Symfony includes the following normalizers but you can also
25-
:doc:`create your own normalizer </serializer/custom_normalizer>`:
26-
27-
* :class:`Symfony\\Component\\Serializer\\Normalizer\\ObjectNormalizer` to
28-
normalize PHP object using the :doc:`PropertyAccess component </components/property_access>`;
29-
* :class:`Symfony\\Component\\Serializer\\Normalizer\\DateTimeZoneNormalizer`
30-
for :phpclass:`DateTimeZone` objects
31-
* :class:`Symfony\\Component\\Serializer\\Normalizer\\DateTimeNormalizer` for
32-
objects implementing the :phpclass:`DateTimeInterface` interface
33-
* :class:`Symfony\\Component\\Serializer\\Normalizer\\DateIntervalNormalizer`
34-
for :phpclass:`DateInterval` objects
35-
* :class:`Symfony\\Component\\Serializer\\Normalizer\\DataUriNormalizer` to
36-
transform :phpclass:`SplFileInfo` objects in `Data URIs`_
37-
* :class:`Symfony\\Component\\Serializer\\Normalizer\\CustomNormalizer` to
38-
normalize PHP object using an object that implements
39-
:class:`Symfony\\Component\\Serializer\\Normalizer\\NormalizableInterface`;
40-
* :class:`Symfony\\Component\\Serializer\\Normalizer\\GetSetMethodNormalizer` to
41-
normalize PHP object using the getter and setter methods of the object;
42-
* :class:`Symfony\\Component\\Serializer\\Normalizer\\PropertyNormalizer` to
43-
normalize PHP object using `PHP reflection`_.
44-
* :class:`Symfony\\Component\\Serializer\\Normalizer\\ConstraintViolationListNormalizer` for objects implementing the :class:`Symfony\\Component\\Validator\\ConstraintViolationListInterface` interface
45-
* :class:`Symfony\\Component\\Serializer\\Normalizer\\ProblemNormalizer` for :class:`Symfony\\Component\\ErrorHandler\\Exception\\FlattenException` objects
46-
* :class:`Symfony\\Component\\Serializer\\Normalizer\\JsonSerializableNormalizer`
47-
to deal with objects implementing the :phpclass:`JsonSerializable` interface
48-
49-
.. _`Data URIs`: https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/Data_URIs
50-
.. _`PHP reflection`: https://php.net/manual/en/book.reflection.php
24+
Symfony includes several types of :ref:`built-in normalizers <component-serializer-normalizers>`
25+
but you can also :doc:`create your own normalizer </serializer/custom_normalizer>`.

0 commit comments

Comments
 (0)