1
0
mirror of https://github.com/danog/psalm.git synced 2025-01-22 05:41:20 +01:00

Combine value types at once

This commit is contained in:
Bruce Weirdan 2021-08-10 21:30:57 +03:00
parent a41d5c5b4f
commit a64a30cdda
No known key found for this signature in database
GPG Key ID: CFC3AAB181751B0D

View File

@ -431,7 +431,7 @@ class SimpleTypeInferer
}
$item_key_type_atomic = [];
$item_value_type = null;
$item_value_type_atomic = [];
$property_types = [];
$class_strings = [];
@ -527,18 +527,10 @@ class SimpleTypeInferer
}
}
if ($item_value_type) {
$item_value_type = Type::combineUnionTypes(
$single_item_value_type,
$item_value_type,
null,
false,
true,
30
);
} else {
$item_value_type = $single_item_value_type;
}
$item_value_type_atomic = array_merge(
$item_value_type_atomic,
array_values($single_item_value_type->getAtomicTypes())
);
}
$item_key_type = null;
@ -552,6 +544,17 @@ class SimpleTypeInferer
);
}
$item_value_type = null;
if ($item_value_type_atomic) {
$item_value_type = TypeCombiner::combine(
$item_value_type_atomic,
null,
false,
true,
30
);
}
// if this array looks like an object-like array, let's return that instead
if ($item_value_type
&& $item_key_type