Skip to content

Commit eaa26a9

Browse files
committed
Code clean up.
1 parent dfc3c13 commit eaa26a9

1 file changed

Lines changed: 8 additions & 3 deletions

File tree

‎src/Type/Php/FilterFunctionReturnTypeHelper.php‎

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
use PHPStan\Type\UnionType;
3131
use function array_key_exists;
3232
use function array_merge;
33+
use function count;
3334
use function hexdec;
3435
use function is_int;
3536
use function octdec;
@@ -415,9 +416,13 @@ private function determineExactType(Type $in, int $filterValue, Type $defaultTyp
415416
$inString = $in->toString();
416417
if ($inString instanceof UnionType) {
417418
return $inString->traverse(
418-
static fn (Type $type): Type => $type->getConstantStrings() === [$type] && $type->getValue() === ''
419-
? new NullType()
420-
: $type,
419+
static function (Type $type): Type {
420+
$typeConstantStrings = $type->getConstantStrings();
421+
if (count($typeConstantStrings) === 1 && $typeConstantStrings[0]->getValue() === '') {
422+
return new NullType();
423+
}
424+
return $type;
425+
},
421426
);
422427
}
423428

0 commit comments

Comments
 (0)