Skip to content

Commit 4d7deea

Browse files
authored
fix(jsonld): check if supportedTypes exists (#6825)
1 parent 7c9cca6 commit 4d7deea

File tree

2 files changed

+13
-3
lines changed

2 files changed

+13
-3
lines changed

src/JsonLd/Serializer/ErrorNormalizer.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,10 @@ public function supportsNormalization(mixed $data, ?string $format = null, array
5858

5959
public function getSupportedTypes(?string $format): array
6060
{
61-
return $this->inner->getSupportedTypes($format);
61+
if (method_exists($this->inner, 'getSupportedTypes')) {
62+
return $this->inner->getSupportedTypes($format);
63+
}
64+
65+
return [];
6266
}
6367
}

src/Metadata/Util/PropertyInfoToTypeInfoHelper.php

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
use Symfony\Component\TypeInfo\Exception\InvalidArgumentException;
1818
use Symfony\Component\TypeInfo\Type;
1919
use Symfony\Component\TypeInfo\Type\BuiltinType;
20+
use Symfony\Component\TypeInfo\Type\NullableType;
2021
use Symfony\Component\TypeInfo\Type\UnionType;
2122
use Symfony\Component\TypeInfo\TypeIdentifier;
2223

@@ -126,11 +127,16 @@ public static function createTypeFromLegacyValues(string $builtinType, bool $nul
126127

127128
public static function unwrapNullableType(Type $type): Type
128129
{
129-
if (!$type instanceof UnionType) {
130+
// BC layer for "symfony/type-info" < 7.2
131+
if (method_exists($type, 'asNonNullable')) {
132+
return (!$type instanceof UnionType) ? $type : $type->asNonNullable();
133+
}
134+
135+
if (!$type instanceof NullableType) {
130136
return $type;
131137
}
132138

133-
return $type->asNonNullable();
139+
return $type->getWrappedType();
134140
}
135141

136142
/**

0 commit comments

Comments
 (0)