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:
parent
aec64c1a39
commit
f4f4a32f08
@ -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) {
|
||||
|
@ -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();'
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user