mirror of
https://github.com/danog/psalm.git
synced 2024-11-26 20:34:47 +01:00
Add a bit more accuracy
This commit is contained in:
parent
e26922010a
commit
b8ebed0b85
@ -245,11 +245,16 @@ class Taint
|
||||
$fetch_nesting--;
|
||||
}
|
||||
|
||||
if ($previous_path_type === 'array-fetch') {
|
||||
if (substr($previous_path_type, 0, 11) === 'array-fetch') {
|
||||
$fetch_nesting++;
|
||||
}
|
||||
|
||||
if (strpos($previous_path_type, 'array-assignment-') === 0) {
|
||||
if ($fetch_nesting > 0) {
|
||||
$fetch_nesting--;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (substr($previous_path_type, 17) === substr($path_type, 12)) {
|
||||
break;
|
||||
}
|
||||
|
@ -427,6 +427,13 @@ class TaintTest extends TestCase
|
||||
echo $m["b"];
|
||||
}'
|
||||
],
|
||||
'taintFreeNestedArrayWithOffsetAccessedExplicitly' => [
|
||||
'<?php
|
||||
$a = [];
|
||||
$a[] = ["a" => $_GET["name"], "b" => "foo"];
|
||||
|
||||
echo $a[0]["b"];',
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
@ -1267,6 +1274,24 @@ class TaintTest extends TestCase
|
||||
echo $m->taint;',
|
||||
'error_message' => 'TaintedInput',
|
||||
],
|
||||
'taintNestedArrayWithOffsetAccessedInForeach' => [
|
||||
'<?php
|
||||
$a = [];
|
||||
$a[0] = ["a" => $_GET["name"], "b" => "foo"];
|
||||
|
||||
foreach ($a as $m) {
|
||||
echo $m["a"];
|
||||
}',
|
||||
'error_message' => 'TaintedInput',
|
||||
],
|
||||
'taintNestedArrayWithOffsetAccessedExplicitly' => [
|
||||
'<?php
|
||||
$a = [];
|
||||
$a[] = ["a" => $_GET["name"], "b" => "foo"];
|
||||
|
||||
echo $a[0]["a"];',
|
||||
'error_message' => 'TaintedInput',
|
||||
],
|
||||
];
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user