Skip to content

Commit

Permalink
Mixed contain every types and Never is contained in every type
Browse files Browse the repository at this point in the history
  • Loading branch information
orklah committed Nov 5, 2021
1 parent b783468 commit de9ad68
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions src/Psalm/Internal/Type/Comparator/UnionTypeComparator.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,14 @@ public static function isContainedBy(
bool $allow_interface_equality = false,
bool $allow_float_int_equality = true
) : bool {
if ($container_type->isMixed()) {
return true;
}

if ($input_type->isNever()) {
return true;
}

if ($union_comparison_result) {
$union_comparison_result->scalar_type_match_found = true;
}
Expand Down Expand Up @@ -317,6 +325,10 @@ public static function isContainedByInPhp(
return false;
}

if ($input_type->isNever()) {
return true;
}

if ($input_type->getId() === $container_type->getId()) {
return true;
}
Expand Down Expand Up @@ -357,6 +369,10 @@ public static function canBeContainedBy(
return true;
}

if ($input_type->isNever()) {
return true;
}

if ($input_type->possibly_undefined && !$container_type->possibly_undefined) {
return false;
}
Expand Down

0 comments on commit de9ad68

Please sign in to comment.