Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. DisallowLongArraySyntaxSniff.php

class DisallowLongArraySyntaxSniff

Same name in this branch
  1. 11.1.x vendor/squizlabs/php_codesniffer/src/Standards/Generic/Sniffs/Arrays/DisallowLongArraySyntaxSniff.php \PHP_CodeSniffer\Standards\Generic\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 \PHP_CodeSniffer\Standards\Generic\Sniffs\Arrays\DisallowLongArraySyntaxSniff implements \PHP_CodeSniffer\Sniffs\Sniff
    • class \Drupal\Sniffs\Arrays\DisallowLongArraySyntaxSniff extends \PHP_CodeSniffer\Standards\Generic\Sniffs\Arrays\DisallowLongArraySyntaxSniff

Expanded class hierarchy of DisallowLongArraySyntaxSniff

File

vendor/drupal/coder/coder_sniffer/Drupal/Sniffs/Arrays/DisallowLongArraySyntaxSniff.php, line 23

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) {
            // No need to check this file again, mark it as done.
            return $phpcsFile->numTokens + 1;
        }
        parent::process($phpcsFile, $stackPtr);
    }
    
    //end process()

}

Members

Title Sort descending Modifiers Object type Summary Overriden Title
DisallowLongArraySyntaxSniff::process public function Processes this test, when one of its tokens is encountered. Overrides DisallowLongArraySyntaxSniff::process
DisallowLongArraySyntaxSniff::register public function Registers the tokens that this sniff wants to listen for. Overrides Sniff::register
RSS feed
Powered by Drupal