You are here

public function FunctionDefinition::process in Coder 8.2

Same name and namespace in other branches
  1. 8.3 coder_sniffer/Drupal/Sniffs/Semantics/FunctionDefinition.php \Drupal\Sniffs\Semantics\FunctionDefinition::process()
  2. 8.3.x coder_sniffer/Drupal/Sniffs/Semantics/FunctionDefinition.php \Drupal\Sniffs\Semantics\FunctionDefinition::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

File

coder_sniffer/Drupal/Sniffs/Semantics/FunctionDefinition.php, line 48

Class

FunctionDefinition
Helper class to sniff for function definitions.

Namespace

Drupal\Sniffs\Semantics

Code

public function process(File $phpcsFile, $stackPtr) {
  $tokens = $phpcsFile
    ->getTokens();

  // Check if this is a function definition.
  $functionPtr = $phpcsFile
    ->findPrevious(Tokens::$emptyTokens, $stackPtr - 1, null, true);
  if ($tokens[$functionPtr]['code'] === T_FUNCTION) {
    $this
      ->processFunction($phpcsFile, $stackPtr, $functionPtr);
  }
}