mirror of
https://github.com/danog/psalm.git
synced 2025-01-22 05:41:20 +01:00
Allow combination of mixed-from-isset and empty
This commit is contained in:
parent
f02fdeddf3
commit
09ea7ba7a8
@ -306,10 +306,12 @@ class TypeCombination
|
|||||||
$new_types = array_merge($new_types, array_values($combination->floats));
|
$new_types = array_merge($new_types, array_values($combination->floats));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$has_empty = (int) isset($combination->value_types['empty']);
|
||||||
|
|
||||||
foreach ($combination->value_types as $type) {
|
foreach ($combination->value_types as $type) {
|
||||||
if ($type instanceof TMixed
|
if ($type instanceof TMixed
|
||||||
&& $combination->mixed_from_loop_isset
|
&& $combination->mixed_from_loop_isset
|
||||||
&& (count($combination->value_types) > 1 || count($new_types))
|
&& (count($combination->value_types) > (1 + $has_empty) || count($new_types) > $has_empty)
|
||||||
) {
|
) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -323,6 +325,10 @@ class TypeCombination
|
|||||||
$new_types[] = $type;
|
$new_types[] = $type;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!$new_types) {
|
||||||
|
throw new \UnexpectedValueException('There should be types here');
|
||||||
|
}
|
||||||
|
|
||||||
$union_type = new Union($new_types);
|
$union_type = new Union($new_types);
|
||||||
|
|
||||||
if ($from_docblock) {
|
if ($from_docblock) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user