New in Symfony 7.2: Serializer Improvements


In Symfony 7.2, we improved the Serializer component with some new features.

Support DateTime Subclasses

Contributed by
Attila Szeremi
in
#57793

The current DateTimeNormalizer used by the Serializer component, only normalizes
objects of types \DateTimeInterface, \DateTimeImmutable, and \DateTime.
In Symfony 7.2, we improved this normalizer to process any object that extends
\DateTimeInterface.

Add a SnakeCase Name Converter

Contributed by
Kévin Dunglas
in
#58060

Symfony Serializer already includes a camelCase to snake_case name converter.
In Symfony 7.2, we've added the SnakeCaseToCamelCaseNameConverter class to
perform the opposite conversion (e.g. last_name -> lastName).
Indirectly related, we've also deprecated the AdvancedNameConverterInterface
in favor of the existing NameConverterInterface (see PR #58308).

Add new UUID Constants

Contributed by
Alexandre Daubois
in
#58246

The UidNormalizer included in the Serializer component provides constants for
various UID formats (NORMALIZATION_FORMAT_*). In Symfony 7.2 we've added new
one UidNormalizer::NORMALIZATION_FORMAT_RFC9562 to complete the list of available formats.

Decouple the Webhook Component from the Serializer

Contributed by
Christian Flothmann
in
#57881

The Webhook component uses the Serializer to turn payloads into JSON contents.
This is a hardcoded dependency, which we try to avoid in Symfony components as much
as possible. That's why in Symfony 7.2 this dependency is now optional. If the
Serializer is not installed, the Webhook component will fall back to using the
native json_encode() function from PHP.

Sponsor the Symfony project.