Skip to content

Commit

Permalink
Avoid false positive for param
Browse files Browse the repository at this point in the history
  • Loading branch information
muglug committed May 2, 2019
1 parent 4f26c8d commit 86bf159
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
Expand Up @@ -28,8 +28,6 @@ public static function analyze(
PhpParser\Node\Expr\Ternary $stmt,
Context $context
) {
$context->referenced_var_ids = [];

$first_if_cond_expr = IfAnalyzer::getDefinitelyEvaluatedExpression($stmt->cond);

$context->inside_conditional = true;
Expand Down
13 changes: 11 additions & 2 deletions tests/UnusedVariableTest.php
Expand Up @@ -908,8 +908,17 @@ function example2() : int {
* @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;
}
}',
],
];
Expand Down

0 comments on commit 86bf159

Please sign in to comment.