diff --git a/src/Psalm/Internal/Analyzer/Statements/Expression/Assignment/ArrayAssignmentAnalyzer.php b/src/Psalm/Internal/Analyzer/Statements/Expression/Assignment/ArrayAssignmentAnalyzer.php index fe7396406..bcfb41b41 100644 --- a/src/Psalm/Internal/Analyzer/Statements/Expression/Assignment/ArrayAssignmentAnalyzer.php +++ b/src/Psalm/Internal/Analyzer/Statements/Expression/Assignment/ArrayAssignmentAnalyzer.php @@ -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]); diff --git a/src/Psalm/Internal/Provider/ReturnTypeProvider/ArrayMergeReturnTypeProvider.php b/src/Psalm/Internal/Provider/ReturnTypeProvider/ArrayMergeReturnTypeProvider.php index ea052d166..678fb25f9 100644 --- a/src/Psalm/Internal/Provider/ReturnTypeProvider/ArrayMergeReturnTypeProvider.php +++ b/src/Psalm/Internal/Provider/ReturnTypeProvider/ArrayMergeReturnTypeProvider.php @@ -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; } diff --git a/src/Psalm/Internal/Provider/ReturnTypeProvider/ArrayReverseReturnTypeProvider.php b/src/Psalm/Internal/Provider/ReturnTypeProvider/ArrayReverseReturnTypeProvider.php index 0ce77dada..06683ca2d 100644 --- a/src/Psalm/Internal/Provider/ReturnTypeProvider/ArrayReverseReturnTypeProvider.php +++ b/src/Psalm/Internal/Provider/ReturnTypeProvider/ArrayReverseReturnTypeProvider.php @@ -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(); } diff --git a/src/Psalm/Type/Atomic/TKeyedArray.php b/src/Psalm/Type/Atomic/TKeyedArray.php index 18f5f4ea4..137e16909 100644 --- a/src/Psalm/Type/Atomic/TKeyedArray.php +++ b/src/Psalm/Type/Atomic/TKeyedArray.php @@ -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) {