You are here

class DisallowLongArraySyntaxSniff 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
  2. 8.3.x coder_sniffer/Drupal/Sniffs/Arrays/DisallowLongArraySyntaxSniff.php \Drupal\Sniffs\Arrays\DisallowLongArraySyntaxSniff

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

@category PHP @package PHP_CodeSniffer @link http://pear.php.net/package/PHP_CodeSniffer

Hierarchy

  • class \Drupal\Sniffs\Arrays\DisallowLongArraySyntaxSniff extends \PHP_CodeSniffer\Standards\Generic\Sniffs\Arrays\DisallowLongArraySyntaxSniff

Expanded class hierarchy of DisallowLongArraySyntaxSniff

File

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

Namespace

Drupal\Sniffs\Arrays
View source
class DisallowLongArraySyntaxSniff extends GenericDisallowLongArraySyntaxSniff {

  /**
   * Processes this test, when one of its tokens is encountered.
   *
   * @param \PHP_CodeSniffer\Files\File $phpcsFile The file being scanned.
   * @param int                         $stackPtr  The position of the current token
   *                                               in the stack passed in $tokens.
   *
   * @return void|int
   */
  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);
  }

}

Members

Namesort descending Modifiers Type Description Overrides
DisallowLongArraySyntaxSniff::process public function Processes this test, when one of its tokens is encountered.