Skip to content

Commit

Permalink
Keep NeverType isExplicit-flag in TypeCombinator::intersect()
Browse files Browse the repository at this point in the history
  • Loading branch information
staabm authored and ondrejmirtes committed Dec 15, 2022
1 parent b76e7b1 commit b2e1a09
Show file tree
Hide file tree
Showing 2 changed files with 91 additions and 53 deletions.
6 changes: 3 additions & 3 deletions src/Type/TypeCombinator.php
Expand Up @@ -946,7 +946,7 @@ public static function intersect(Type ...$types): Type
$valueType = $types[$j]->getValueType();
$newValueType = self::intersect($types[$i]->getOffsetValueType($offsetType), $valueType);
if ($newValueType instanceof NeverType) {
return new NeverType();
return $newValueType;
}
$types[$i] = $types[$i]->setOffsetValueType($offsetType, $newValueType);
array_splice($types, $j--, 1);
Expand All @@ -959,7 +959,7 @@ public static function intersect(Type ...$types): Type
$valueType = $types[$i]->getValueType();
$newValueType = self::intersect($types[$j]->getOffsetValueType($offsetType), $valueType);
if ($newValueType instanceof NeverType) {
return new NeverType();
return $newValueType;
}

$types[$j] = $types[$j]->setOffsetValueType($offsetType, $newValueType);
Expand Down Expand Up @@ -1044,7 +1044,7 @@ public static function intersect(Type ...$types): Type
) {
$keyType = self::intersect($types[$i]->getIterableKeyType(), $types[$j]->getIterableKeyType());
if ($keyType instanceof NeverType) {
return new NeverType();
return $keyType;
}
$types[$i] = new ArrayType($keyType, $types[$i]->getItemType());
continue;
Expand Down

0 comments on commit b2e1a09

Please sign in to comment.