Skip to content

Commit 4e82081

Browse files
committed
keep TypehintHelper remove null
1 parent 993bfbd commit 4e82081

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/Type/TypehintHelper.php

+4-2
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,6 @@ public static function decideTypeFromReflection(
6868
$type = ParserNodeTypeToPHPStanType::resolve($typeNode, $selfClass);
6969
if ($reflectionType->allowsNull()) {
7070
$type = TypeCombinator::addNull($type);
71-
} elseif ($phpDocType !== null) {
72-
$phpDocType = TypeCombinator::removeNull($phpDocType);
7371
}
7472

7573
return self::decideType($type, $phpDocType);
@@ -80,6 +78,10 @@ public static function decideType(
8078
?Type $phpDocType,
8179
): Type
8280
{
81+
if ($phpDocType !== null && $type->isNull()->no()) {
82+
$phpDocType = TypeCombinator::removeNull($phpDocType);
83+
}
84+
8385
if ($type instanceof BenevolentUnionType) {
8486
return $type;
8587
}

0 commit comments

Comments
 (0)