diff --git a/src/Psalm/Internal/Analyzer/Statements/Expression/Assignment/ArrayAssignmentAnalyzer.php b/src/Psalm/Internal/Analyzer/Statements/Expression/Assignment/ArrayAssignmentAnalyzer.php index f1890d3de..7c3c80119 100644 --- a/src/Psalm/Internal/Analyzer/Statements/Expression/Assignment/ArrayAssignmentAnalyzer.php +++ b/src/Psalm/Internal/Analyzer/Statements/Expression/Assignment/ArrayAssignmentAnalyzer.php @@ -653,15 +653,15 @@ class ArrayAssignmentAnalyzer [...array_fill( $atomic_root_type_array->getMinCount(), count($atomic_root_type_array->properties)-1, - $array_atomic_type_list + $array_atomic_type_list, ), ...array_fill( 0, count($atomic_root_type_array->properties)-1, - Type::getNever() + Type::getNever(), )], null, null, - true + true, ); } $from_countable_object_like = true; diff --git a/src/Psalm/Type/Atomic/TKeyedArray.php b/src/Psalm/Type/Atomic/TKeyedArray.php index 11a1ccf4a..f673af9d0 100644 --- a/src/Psalm/Type/Atomic/TKeyedArray.php +++ b/src/Psalm/Type/Atomic/TKeyedArray.php @@ -25,6 +25,7 @@ use function get_class; use function implode; use function is_int; use function is_string; +use function ksort; use function preg_match; use function sort; use function str_replace; diff --git a/tests/ArrayAccessTest.php b/tests/ArrayAccessTest.php index 7538885ef..e4fba8b6a 100644 --- a/tests/ArrayAccessTest.php +++ b/tests/ArrayAccessTest.php @@ -453,7 +453,7 @@ class ArrayAccessTest extends TestCase 'assertions' => [ '$pre===' => 'list{0?: 0|1, 1?: 1}', '$a===' => 'list{0: 0|1|2, 1?: 1|2, 2?: 2}', - ] + ], ], 'testBuildListOther' => [ 'code' => ' [ - '$list===' => "list{0: 'A'|'B'|'C', 1?: 'C'}" - ] + '$list===' => "list{0: 'A'|'B'|'C', 1?: 'C'}", + ], ], 'instanceOfStringOffset' => [ 'code' => ' */ function ret() { - return [1, 1, 1]; + return [new a, new a, new a]; } $result = ret();