You are here

public function Drupal_Sniffs_Semantics_FunctionCallSniff::process in Coder 7.2

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

Parameters

PHP_CodeSniffer_File $phpcsFile The file being scanned.:

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

Return value

void

File

coder_sniffer/Drupal/Sniffs/Semantics/FunctionCallSniff.php, line 87

Class

Drupal_Sniffs_Semantics_FunctionCallSniff
Helper class to sniff for specific function calls.

Code

public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr) {
  $tokens = $phpcsFile
    ->getTokens();
  $functionName = $tokens[$stackPtr]['content'];
  if (isset(self::$listeners[$functionName]) === false) {

    // No listener is interested in this function name, so return early.
    return;
  }
  if ($this
    ->isFunctionCall($phpcsFile, $stackPtr) === false) {
    return;
  }

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