1
0
mirror of https://github.com/danog/psalm.git synced 2024-11-30 04:39:00 +01:00

Taint mixed keys too

This commit is contained in:
Matt Brown 2021-03-24 16:42:22 -04:00
parent 30f64b79de
commit 929f931c14
2 changed files with 10 additions and 1 deletions

View File

@ -481,13 +481,14 @@ class ForeachAnalyzer
) {
$has_valid_iterator = true;
$value_type = Type::getMixed();
$key_type = Type::getMixed();
ArrayFetchAnalyzer::taintArrayFetch(
$statements_analyzer,
$expr,
null,
$value_type,
Type::getMixed()
$key_type
);
if (!$context->pure) {

View File

@ -3290,6 +3290,14 @@ class UnusedVariableTest extends TestCase
}',
'error_message' => 'MixedAssignment - src' . DIRECTORY_SEPARATOR . 'somefile.php:3:42 - Unable to determine the type that $key is being assigned to. Consider improving the type at src' . DIRECTORY_SEPARATOR . 'somefile.php:2:43'
],
'warnAboutMixedKeySource' => [
'<?php
/** @param mixed $arr */
function foo($arr) : void {
foreach ($arr as $key => $_) {}
}',
'error_message' => 'MixedAssignment - src' . DIRECTORY_SEPARATOR . 'somefile.php:4:42 - Unable to determine the type that $key is being assigned to. Consider improving the type at src' . DIRECTORY_SEPARATOR . 'somefile.php:3:34'
],
];
}
}