You are here

public function DisallowLongArraySyntaxSniff::process in Coder 8.2

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

File

coder_sniffer/Drupal/Sniffs/Arrays/DisallowLongArraySyntaxSniff.php, line 38

Class

DisallowLongArraySyntaxSniff
Bans the use of the PHP long array syntax in Drupal 8.

Namespace

Drupal\Sniffs\Arrays

Code

public function process(File $phpcsFile, $stackPtr) {
  $drupalVersion = Project::getCoreVersion($phpcsFile);
  if ($drupalVersion !== '8.x') {

    // No need to check this file again, mark it as done.
    return $phpcsFile->numTokens + 1;
  }
  return parent::process($phpcsFile, $stackPtr);
}