Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Keep NeverType isExplicit-flag in TypeCombinator::intersect() #2112

Merged
merged 1 commit into from Dec 15, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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();
Copy link
Contributor Author

@staabm staabm Dec 14, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

these lines dropped the explicitness flag before this PR

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