mirror of
https://github.com/danog/psalm.git
synced 2024-11-27 04:45:20 +01:00
Merge pull request #8816 from weirdan/fix-8313
Fixes https://github.com/vimeo/psalm/issues/8313
This commit is contained in:
commit
e64913c377
@ -524,17 +524,19 @@ class InstancePropertyAssignmentAnalyzer
|
||||
}
|
||||
}
|
||||
|
||||
$stmt_var_type = $context->vars_in_scope[$var_id]->setParentNodes(
|
||||
[$var_node->id => $var_node]
|
||||
);
|
||||
if (isset($context->vars_in_scope[$var_id])) {
|
||||
$stmt_var_type = $context->vars_in_scope[$var_id]->setParentNodes(
|
||||
[$var_node->id => $var_node]
|
||||
);
|
||||
|
||||
if ($context->vars_in_scope[$var_id]->parent_nodes) {
|
||||
foreach ($context->vars_in_scope[$var_id]->parent_nodes as $parent_node) {
|
||||
$data_flow_graph->addPath($parent_node, $var_node, '=', $added_taints, $removed_taints);
|
||||
if ($context->vars_in_scope[$var_id]->parent_nodes) {
|
||||
foreach ($context->vars_in_scope[$var_id]->parent_nodes as $parent_node) {
|
||||
$data_flow_graph->addPath($parent_node, $var_node, '=', $added_taints, $removed_taints);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$context->vars_in_scope[$var_id] = $stmt_var_type;
|
||||
$context->vars_in_scope[$var_id] = $stmt_var_type;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if ($statements_analyzer->data_flow_graph instanceof TaintFlowGraph
|
||||
|
@ -1742,6 +1742,21 @@ class UnusedCodeTest extends TestCase
|
||||
',
|
||||
'error_message' => 'UnevaluatedCode',
|
||||
],
|
||||
'noCrashOnReadonlyStaticProp' => [
|
||||
'code' => '<?php
|
||||
/** @psalm-immutable */
|
||||
final class C { public int $val = 2; }
|
||||
|
||||
final class A {
|
||||
private static C $prop;
|
||||
public static function f()
|
||||
{
|
||||
self::$prop->val = 1;
|
||||
}
|
||||
}
|
||||
',
|
||||
'error_message' => 'InaccessibleProperty',
|
||||
],
|
||||
];
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user