You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feature #2607 [LiveComponent] Fix PropertyTypeExtractorInterface::getTypes() deprecation, use TypeInfo ^7.2 Type (mtarld)
This PR was merged into the 2.x branch.
Discussion
----------
[LiveComponent] Fix `PropertyTypeExtractorInterface::getTypes()` deprecation, use TypeInfo ^7.2 `Type`
| Q | A
| ------------- | ---
| Bug fix? | no
| New feature? | yes
| Issues | Fix#1708, fix#2778
| License | MIT
Fix the `PropertyTypeExtractorInterface::getTypes()` deprecation and use `PropertyTypeExtractorInterface::getType()` (based on TypeInfo `Type`) instead.
This PR allows TypeInfo ^7.2 to be used, thanks to the compatibility layers added for `Type::accepts()` and `Type::traverse()` (added in 7.3). In order to reduce frictions when users will upgrade their apps dependencies.
The CI changed a bit too:
- When testing LiveComponent, with PHP 8.2, we install `symfony/property-info:7.1.* symfony/type-info:7.2.*`
- When testing LiveComponent, with PHP 8.3, we install `symfony/property-info:7.2.* symfony/type-info:7.2.*`
- When testing LiveComponent, with PHP 8.4, we install `symfony/property-info:7.3.* symfony/type-info:7.3.*`
- When testing LiveComponent, with PHP 8.4 (and dev deps), we install `symfony/property-info:>=7.3 symfony/type-info:>=7.3`
Allowing us to covers a maximum versions of PropertyInfo and TypeInfo.
Commits
-------
7a08cce [LiveComponent] Fix `PropertyTypeExtractorInterface::getTypes()`` deprecation, use TypeInfo ^7.2 `Type`
thrownew \LogicException(\sprintf('Method "%s::%s()" should return an instance of "%s" (given: "%s").', $component::class, $modifier, LiveProp::class, get_debug_type($modifiedLiveProp)));
if ($typeinstanceof \ReflectionUnionType || $typeinstanceof \ReflectionIntersectionType) {
79
-
thrownew \LogicException(\sprintf('Union or intersection types are not supported for LiveProps. You may want to change the type of property %s in %s.', $property->getName(), $property->getDeclaringClass()->getName()));
80
-
}
80
+
// BC layer when "symfony/type-info" is not available
81
+
if (!method_exists($this->propertyTypeExtractor, 'getType')) {
82
+
$type = $property->getType();
83
+
if ($typeinstanceof \ReflectionUnionType || $typeinstanceof \ReflectionIntersectionType) {
84
+
thrownew \LogicException(\sprintf('Union or intersection types are not supported for LiveProps. You may want to change the type of property %s in %s.', $property->getName(), $property->getDeclaringClass()->getName()));
if ($typeinstanceof UnionType && !$typeinstanceof NullableType || $typeinstanceof IntersectionType) {
121
+
thrownew \LogicException(\sprintf('Union or intersection types are not supported for LiveProps. You may want to change the type of property "%s" in "%s".', $propertyName, $className));
0 commit comments