1
0
mirror of https://github.com/danog/psalm.git synced 2024-12-13 01:37:23 +01:00

allow Literals to be combined with preexisting IntRange

This commit is contained in:
orklah 2021-09-13 21:29:06 +02:00
parent 086d3777eb
commit 81e8bf3ff5

View File

@ -1200,6 +1200,24 @@ class TypeCombiner
}
);
if (isset($combination->value_types['int'])) {
$current_int_type = $combination->value_types['int'];
if ($current_int_type instanceof TIntRange) {
foreach ($combination->ints as $int) {
if (!$current_int_type->contains($int->value)) {
$current_int_type->min_bound = TIntRange::getNewLowestBound(
$current_int_type->min_bound,
$int->value
);
$current_int_type->max_bound = TIntRange::getNewHighestBound(
$current_int_type->max_bound,
$int->value
);
}
}
}
}
$combination->ints = null;
if (!isset($combination->value_types['int'])) {