mirror of
https://github.com/danog/psalm.git
synced 2024-12-02 17:52:45 +01:00
Generate properly shaped lists when appending
This commit is contained in:
parent
909edb48e3
commit
2b9512ef50
@ -590,6 +590,11 @@ class ArrayAssignmentAnalyzer
|
||||
$array_atomic_type_class_string->getStandinKeyParam(),
|
||||
$array_atomic_type_class_string->value_param
|
||||
]);
|
||||
} elseif ($atomic_root_types['array'] instanceof TKeyedArray
|
||||
&& $atomic_root_types['array']->is_list
|
||||
&& $atomic_root_types['array']->fallback_params === null
|
||||
) {
|
||||
$array_atomic_type = $atomic_root_types['array'];
|
||||
} elseif ($atomic_root_types['array'] instanceof TNonEmptyArray
|
||||
|| ($atomic_root_types['array'] instanceof TKeyedArray
|
||||
&& $atomic_root_types['array']->is_list
|
||||
|
@ -2011,6 +2011,21 @@ class ArrayAssignmentTest extends TestCase
|
||||
if (\array_key_exists($currentAction, $items)) {
|
||||
$items[$currentAction]["active"] = true;
|
||||
}'
|
||||
],
|
||||
'listAppendShape' => [
|
||||
'code' => '<?php
|
||||
$a = [];
|
||||
$a[]= 0;
|
||||
$a[]= 1;
|
||||
$a[]= 2;
|
||||
|
||||
$b = [0];
|
||||
$b[]= 1;
|
||||
$b[]= 2;',
|
||||
'assertions' => [
|
||||
'$a===' => 'list{0, 1, 2}',
|
||||
'$b===' => 'list{0, 1, 2}'
|
||||
]
|
||||
]
|
||||
];
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user