From 2b9e61391217ea7ba06ad72036c5cfe4e42eb040 Mon Sep 17 00:00:00 2001 From: soyuka Date: Tue, 26 Nov 2024 08:15:01 +0100 Subject: [PATCH 1/2] fix(jsonld): check if supportedTypes exists --- src/JsonLd/Serializer/ErrorNormalizer.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/JsonLd/Serializer/ErrorNormalizer.php b/src/JsonLd/Serializer/ErrorNormalizer.php index d1b27e9d3f0..67f1ba43dc1 100644 --- a/src/JsonLd/Serializer/ErrorNormalizer.php +++ b/src/JsonLd/Serializer/ErrorNormalizer.php @@ -58,6 +58,10 @@ public function supportsNormalization(mixed $data, ?string $format = null, array public function getSupportedTypes(?string $format): array { - return $this->inner->getSupportedTypes($format); + if (method_exists($this->inner, 'getSupportedTypes')) { + return $this->inner->getSupportedTypes($format); + } + + return []; } } From dbdae46d99d3ae5c0f0c66711db80ea1131df065 Mon Sep 17 00:00:00 2001 From: soyuka Date: Fri, 29 Nov 2024 13:28:39 +0100 Subject: [PATCH 2/2] fix: as non nullable --- src/Metadata/Util/PropertyInfoToTypeInfoHelper.php | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/Metadata/Util/PropertyInfoToTypeInfoHelper.php b/src/Metadata/Util/PropertyInfoToTypeInfoHelper.php index 5e4fc475fa1..40be59bad86 100644 --- a/src/Metadata/Util/PropertyInfoToTypeInfoHelper.php +++ b/src/Metadata/Util/PropertyInfoToTypeInfoHelper.php @@ -17,6 +17,7 @@ use Symfony\Component\TypeInfo\Exception\InvalidArgumentException; use Symfony\Component\TypeInfo\Type; use Symfony\Component\TypeInfo\Type\BuiltinType; +use Symfony\Component\TypeInfo\Type\NullableType; use Symfony\Component\TypeInfo\Type\UnionType; use Symfony\Component\TypeInfo\TypeIdentifier; @@ -126,11 +127,16 @@ public static function createTypeFromLegacyValues(string $builtinType, bool $nul public static function unwrapNullableType(Type $type): Type { - if (!$type instanceof UnionType) { + // BC layer for "symfony/type-info" < 7.2 + if (method_exists($type, 'asNonNullable')) { + return (!$type instanceof UnionType) ? $type : $type->asNonNullable(); + } + + if (!$type instanceof NullableType) { return $type; } - return $type->asNonNullable(); + return $type->getWrappedType(); } /**