1
0
mirror of https://github.com/danog/psalm.git synced 2025-01-21 21:31:13 +01:00

Fix #2062 - treat function inside variable method call name as used

This commit is contained in:
Matthew Brown 2019-08-26 00:47:46 -04:00
parent aec64c1a39
commit f4f4a32f08
2 changed files with 20 additions and 0 deletions

View File

@ -74,9 +74,14 @@ class MethodCallAnalyzer extends \Psalm\Internal\Analyzer\Statements\Expression\
}
if (!$stmt->name instanceof PhpParser\Node\Identifier) {
$was_inside_call = $context->inside_call;
$context->inside_call = true;
if (ExpressionAnalyzer::analyze($statements_analyzer, $stmt->name, $context) === false) {
return false;
}
if (!$was_inside_call) {
$context->inside_call = false;
}
}
if ($stmt->var instanceof PhpParser\Node\Expr\Variable) {

View File

@ -537,6 +537,21 @@ class UnusedCodeTest extends TestCase
$o->foo("COUNT{$s}");
}'
],
'usedFunctioninMethodCallName' => [
'<?php
class Foo {
/**
* @psalm-suppress MixedArgument
*/
public function bar(): void {
/** @var mixed $action */
$action = "";
$this->{"execute" . ucfirst($action)}($request);
}
}
(new Foo)->bar();'
],
];
}