Tokenizer is able to locate invocations and given parameters for class methods and functions.
Use Spiral\Tokenizer\InvocationsInterface
to gain access to such functionality.
Locate all usages of dump function:
public function indexAction(InvocationsInterface $invocations)
{
dump($invocations->getInvocations(new \ReflectionFunction('dump')));
}
Locate all messages of say
method of TranslatorTrait
and dump it's parameters:
use TranslatorTrait;
public function indexAction(InvocationsInterface $invocations)
{
$invocations = $invocations->getInvocations(new \ReflectionMethod(
TranslatorTrait::class,
'say'
));
foreach ($invocations as $invocation) {
dump($invocation->getArguments());
}
$this->say('hello');
}
Note, current implementation is only capable of locating constructions like
self::method()
,$this->method()
andstatic::method()
, tree based resolutions are currently not implemented (AST support is required).