1
0
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:
Brown 2020-06-25 00:50:52 -04:00
parent b84cf74754
commit e26922010a
2 changed files with 20 additions and 1 deletions

View File

@ -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) {

View File

@ -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"];
}'
],
];
}