Skip to content

Commit dbdae46

Browse files
committed
fix: as non nullable
1 parent 2b9e613 commit dbdae46

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

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)