mirror of
https://github.com/danog/psalm.git
synced 2024-11-26 12:24:49 +01:00
Add missing dataflow population in array spreads (#5059)
Fixes vimeo/psalm#5057
This commit is contained in:
parent
a9235b6ee9
commit
394f7347de
@ -241,6 +241,30 @@ class ArrayAnalyzer
|
||||
$unpacked_array_type
|
||||
);
|
||||
|
||||
if (($data_flow_graph = $statements_analyzer->data_flow_graph)
|
||||
&& $data_flow_graph instanceof \Psalm\Internal\Codebase\VariableUseGraph
|
||||
&& $unpacked_array_type->parent_nodes
|
||||
) {
|
||||
$var_location = new CodeLocation($statements_analyzer->getSource(), $item->value);
|
||||
|
||||
$new_parent_node = \Psalm\Internal\DataFlow\DataFlowNode::getForAssignment(
|
||||
'array',
|
||||
$var_location
|
||||
);
|
||||
|
||||
$data_flow_graph->addNode($new_parent_node);
|
||||
|
||||
foreach ($unpacked_array_type->parent_nodes as $parent_node) {
|
||||
$data_flow_graph->addPath(
|
||||
$parent_node,
|
||||
$new_parent_node,
|
||||
'array-assignment'
|
||||
);
|
||||
}
|
||||
|
||||
$array_creation_info->parent_taint_nodes += [$new_parent_node->id => $new_parent_node];
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -2182,6 +2182,16 @@ class UnusedVariableTest extends TestCase
|
||||
print_r(...$d);
|
||||
}'
|
||||
],
|
||||
'explicitSpread' => [
|
||||
'<?php
|
||||
function f(): array {
|
||||
$s = [1, 2, 3];
|
||||
$b = ["a", "b", "c"];
|
||||
|
||||
$r = [...$s, ...$b];
|
||||
return $r;
|
||||
}'
|
||||
],
|
||||
'funcGetArgs' => [
|
||||
'<?php
|
||||
function validate(bool $b, bool $c) : void {
|
||||
|
Loading…
Reference in New Issue
Block a user