1
0
mirror of https://github.com/danog/psalm.git synced 2024-11-26 20:34:47 +01:00

Avoid false positive for param

This commit is contained in:
Brown 2019-05-02 15:33:47 -04:00
parent 4f26c8d749
commit 86bf159bd0
2 changed files with 11 additions and 4 deletions

View File

@ -28,8 +28,6 @@ class TernaryAnalyzer
PhpParser\Node\Expr\Ternary $stmt,
Context $context
) {
$context->referenced_var_ids = [];
$first_if_cond_expr = IfAnalyzer::getDefinitelyEvaluatedExpression($stmt->cond);
$context->inside_conditional = true;

View File

@ -908,8 +908,17 @@ class UnusedVariableTest extends TestCase
* @psalm-suppress MissingParamType
*/
function foo($a) : void {
$b = "b";
$a->bar([$b]);
$b = "b";
$a->bar([$b]);
}',
],
'paramUsedInsideLoop' => [
'<?php
function foo(int $counter) : void {
foreach ([1, 2, 3] as $_) {
echo ($counter = $counter + 1);
echo rand(0, 1) ? 1 : 0;
}
}',
],
];