PHPStan\Parser\FunctionCallStatementFinder::findFunctionCallInStatements PHP Method

findFunctionCallInStatements() public method

public findFunctionCallInStatements ( array $functionNames, mixed $statements ) : PhpParser\Node | null
$functionNames array
$statements mixed
return PhpParser\Node | null
    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;
    }

Same methods

FunctionCallStatementFinder::findFunctionCallInStatements ( string $functionName, mixed $statements ) : PhpParser\Node | null

Usage Example

Exemplo n.º 1
0
 /**
  * @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;
 }
All Usage Examples Of PHPStan\Parser\FunctionCallStatementFinder::findFunctionCallInStatements
FunctionCallStatementFinder