1
0
mirror of https://github.com/danog/psalm.git synced 2024-12-03 18:17:55 +01:00
This commit is contained in:
Daniil Gentili 2022-11-26 17:11:41 +01:00
parent 51e6b1155d
commit 700e066539
4 changed files with 15 additions and 3 deletions

View File

@ -612,6 +612,7 @@ class ArrayAssignmentAnalyzer
$prop_count
);
} else if ($prop_count !== null) {
assert($array_atomic_type_list !== null);
$array_atomic_type = new TKeyedArray(
array_fill(
0,
@ -640,6 +641,7 @@ class ArrayAssignmentAnalyzer
'parent_nodes' => $root_type->parent_nodes
]);
} else {
assert($array_atomic_type_list !== null);
$array_atomic_type = new TKeyedArray(
array_fill(
0,
@ -660,6 +662,7 @@ class ArrayAssignmentAnalyzer
$array_atomic_type_list
);
} else {
assert($array_atomic_type_array !== null);
$array_atomic_type = new TNonEmptyArray(
$array_atomic_type_array
);
@ -671,7 +674,12 @@ class ArrayAssignmentAnalyzer
?? ($array_atomic_type_list !== null
? Type::getNonEmptyList($array_atomic_type_list)
: null
) ?? new TNonEmptyArray($array_atomic_type_array);
) ?? ($array_atomic_type_array !== null
? new TNonEmptyArray($array_atomic_type_array)
: null
)
;
assert($array_atomic_type !== null);
$array_assignment_type = new Union([$array_atomic_type]);

View File

@ -109,7 +109,10 @@ class ArrayMergeReturnTypeProvider implements FunctionReturnTypeProviderInterfac
} elseif (!$is_replace) {
if ($unpacking_indefinite_number_of_args) {
$added_inner_values = true;
$inner_value_types[] = $type;
$inner_value_types = array_merge(
$inner_value_types,
array_values($type->getAtomicTypes())
);
} else {
$generic_properties[] = $type;
}

View File

@ -45,7 +45,7 @@ class ArrayReverseReturnTypeProvider implements FunctionReturnTypeProviderInterf
? $array_atomic_type
: null;
if (!$first_arg_array) {
if (!$first_arg_array || !$first_arg_type) {
return Type::getArray();
}

View File

@ -341,6 +341,7 @@ class TKeyedArray extends Atomic
return new TArray([$key_type, $value_type]);
}
assert($key_types !== []);
$key_type = TypeCombiner::combine($key_types);
if ($this->fallback_params !== null) {