mirror of
https://github.com/danog/psalm.git
synced 2025-01-22 05:41:20 +01:00
Improve accuracy of array nesting checks
This commit is contained in:
parent
b84cf74754
commit
e26922010a
@ -232,11 +232,21 @@ class Taint
|
||||
}
|
||||
|
||||
if (strpos($path_type, 'array-fetch-') === 0) {
|
||||
$fetch_nesting = 0;
|
||||
|
||||
$previous_path_types = array_reverse($generated_source->path_types);
|
||||
|
||||
foreach ($previous_path_types as $previous_path_type) {
|
||||
if ($previous_path_type === 'array-assignment') {
|
||||
break;
|
||||
if ($fetch_nesting === 0) {
|
||||
break;
|
||||
}
|
||||
|
||||
$fetch_nesting--;
|
||||
}
|
||||
|
||||
if ($previous_path_type === 'array-fetch') {
|
||||
$fetch_nesting++;
|
||||
}
|
||||
|
||||
if (strpos($previous_path_type, 'array-assignment-') === 0) {
|
||||
|
@ -418,6 +418,15 @@ class TaintTest extends TestCase
|
||||
|
||||
echo StringUtility::slugify("hello");'
|
||||
],
|
||||
'taintFreeNestedArray' => [
|
||||
'<?php
|
||||
$a = [];
|
||||
$a[] = ["a" => $_GET["name"], "b" => "foo"];
|
||||
|
||||
foreach ($a as $m) {
|
||||
echo $m["b"];
|
||||
}'
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user