New in Symfony 7.2: Redesigned TypeInfo Component
November 15, 2024 • Published by Javier Eguiluz
Symfony 7.2 is backed by:
Symfony features are covered by the Backward Compatibility Promise, which ensures that you can safely upgrade between minor versions (e.g. from 7.0 to 7.1, 7.2, etc.) without facing any breaking change.
However, some selected features are introduced as experimental features. These are features that could change their API and other behavior based on the feedback received about them. This is what happened to the TypeInfo component, which was introduced as experimental in Symfony 7.1.
The TypeInfo component extracts information about PHP types from method arguments, return types, and raw strings. After using it for a few months in real applications and integrating it into other packages and libraries, we decided to improve it in several ways:
- Introduced
CompositeTypeInterface
andWrappingTypeInterface
to better describe whether a type is composed by several types or wraps one; - Added a
NullableType
, which extendsUnionType
and is aWrappingTypeInterface
, making it much simpler to recognize a nullable type and retrieve its related non-nullable type; - Removed the
__call()
method thatCollectionType
andGenericType
used to forward methods to their wrapped type (because now it's simpler to know if a type wraps another one); - Rename
is*()
tosatisfy*()
and addCompositeTypeInterface::composedTypesSatisfy()
andWrappingTypeInterface::wrappedTypeSatisfy()
methods; - Added many checks to prevent invalid type constructions.
We're now confident that the component has the right architecture and behavior. That's why we no longer consider it an experimental feature, and you can safely use it knowing that we won't introduce breaking changes to it.
Help the Symfony project!
As with any Open-Source project, contributing code or documentation is the most common way to help, but we also have a wide range of sponsoring opportunities.