Skip to content

Commit

Permalink
Only emit PossiblyUndefinedVariable issue on variables
Browse files Browse the repository at this point in the history
  • Loading branch information
muglug committed Mar 6, 2020
1 parent 75a3412 commit 7ea06c7
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -707,7 +707,9 @@ private static function evaluateAribitraryParam(
if (!$context->hasVariable($var_id, $statements_analyzer)
|| $context->vars_in_scope[$var_id]->isNull()
) {
if (!isset($context->vars_in_scope[$var_id])) {
if (!isset($context->vars_in_scope[$var_id])
&& $arg->value instanceof PhpParser\Node\Expr\Variable
) {
if (IssueBuffer::accepts(
new PossiblyUndefinedVariable(
'Variable ' . $var_id
Expand Down
11 changes: 11 additions & 0 deletions tests/MethodCallTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -524,6 +524,17 @@ public function give(): void{
}
}',
],
'unknownMethodCallWithProperty' => [
'<?php
class A {
private string $b = "c";
public function passesByRef(object $a): void {
/** @psalm-suppress MixedMethodCall */
$a->passedByRef($this->b);
}
}',
],
];
}

Expand Down

0 comments on commit 7ea06c7

Please sign in to comment.