diff --git a/src/Psalm/Internal/Analyzer/Statements/Expression/CallAnalyzer.php b/src/Psalm/Internal/Analyzer/Statements/Expression/CallAnalyzer.php index 9ed9e6d313d..8b9483599fe 100644 --- a/src/Psalm/Internal/Analyzer/Statements/Expression/CallAnalyzer.php +++ b/src/Psalm/Internal/Analyzer/Statements/Expression/CallAnalyzer.php @@ -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 diff --git a/tests/MethodCallTest.php b/tests/MethodCallTest.php index 3e8df55d62e..e1af742417a 100644 --- a/tests/MethodCallTest.php +++ b/tests/MethodCallTest.php @@ -524,6 +524,17 @@ public function give(): void{ } }', ], + 'unknownMethodCallWithProperty' => [ + 'passedByRef($this->b); + } + }', + ], ]; }