Skip to content

Commit

Permalink
fix: as non nullable
Browse files Browse the repository at this point in the history
  • Loading branch information
soyuka committed Nov 29, 2024
1 parent 2b9e613 commit dbdae46
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/Metadata/Util/PropertyInfoToTypeInfoHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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();
}

/**
Expand Down

0 comments on commit dbdae46

Please sign in to comment.