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:
parent
30f64b79de
commit
929f931c14
@ -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) {
|
||||
|
@ -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'
|
||||
],
|
||||
];
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user