You are here

public function FunctionCall::process in Coder 8.2

Same name and namespace in other branches
  1. 8.3 coder_sniffer/Drupal/Sniffs/Semantics/FunctionCall.php \Drupal\Sniffs\Semantics\FunctionCall::process()
  2. 8.3.x coder_sniffer/Drupal/Sniffs/Semantics/FunctionCall.php \Drupal\Sniffs\Semantics\FunctionCall::process()

Processes this test, when one of its tokens is encountered.

Parameters

\PHP_CodeSniffer\Files\File $phpcsFile The file being scanned.:

int $stackPtr The position of the current token: in the stack passed in $tokens.

Return value

void

1 method overrides FunctionCall::process()
ThemeSniff::process in coder_sniffer/DrupalPractice/Sniffs/FunctionCalls/ThemeSniff.php
Processes this function call.

File

coder_sniffer/Drupal/Sniffs/Semantics/FunctionCall.php, line 91

Class

FunctionCall
Helper class to sniff for specific function calls.

Namespace

Drupal\Sniffs\Semantics

Code

public function process(File $phpcsFile, $stackPtr) {
  $tokens = $phpcsFile
    ->getTokens();
  $functionName = $tokens[$stackPtr]['content'];
  if (in_array($functionName, $this
    ->registerFunctionNames()) === false) {

    // Not interested in this function.
    return;
  }
  if ($this
    ->isFunctionCall($phpcsFile, $stackPtr) === false) {
    return;
  }

  // Find the next non-empty token.
  $openBracket = $phpcsFile
    ->findNext(Tokens::$emptyTokens, $stackPtr + 1, null, true);
  $this->phpcsFile = $phpcsFile;
  $this->functionCall = $stackPtr;
  $this->openBracket = $openBracket;
  $this->closeBracket = $tokens[$openBracket]['parenthesis_closer'];
  $this->arguments = array();
  $this
    ->processFunctionCall($phpcsFile, $stackPtr, $openBracket, $this->closeBracket);
}