public function findFunctionCallInStatements(array $functionNames, $statements)
{
foreach ($statements as $statement) {
if (is_array($statement)) {
$result = $this->findFunctionCallInStatements($functionNames, $statement);
if ($result !== null) {
return $result;
}
}
if (!$statement instanceof \PhpParser\Node) {
continue;
}
if ($statement instanceof FuncCall && $statement->name instanceof Name) {
if (in_array((string) $statement->name, $functionNames, true)) {
return $statement;
}
}
$result = $this->findFunctionCallInStatements($functionNames, $statement);
if ($result !== null) {
return $result;
}
}
return null;
}
FunctionCallStatementFinder::findFunctionCallInStatements ( string $functionName, mixed $statements ) : PhpParser\Node | null |
/** * @param mixed $nodes * @return bool */ private function callsFuncGetArgs($nodes) : bool { foreach ($nodes as $node) { if (is_array($node)) { if ($this->callsFuncGetArgs($node)) { return true; } } if (!$node instanceof \PhpParser\Node) { continue; } if ($node instanceof \PhpParser\Node\Stmt\ClassLike && isset($node->namespacedName) && $this->declaringClass->getName() !== (string) $node->namespacedName) { continue; } if ($node instanceof ClassMethod) { if ($node->getStmts() === null) { continue; // interface } $methodName = $node->name; if ($methodName === $this->reflection->getName()) { return $this->functionCallStatementFinder->findFunctionCallInStatements(ParametersAcceptor::VARIADIC_FUNCTIONS, $node->getStmts()) !== null; } continue; } if ($this->callsFuncGetArgs($node)) { return true; } } return false; }