Mercurial > hg > isophonics-drupal-site
annotate vendor/drupal/coder/coder_sniffer/Drupal/Sniffs/Arrays/DisallowLongArraySyntaxSniff.php @ 19:fa3358dc1485 tip
Add ndrum files
author | Chris Cannam |
---|---|
date | Wed, 28 Aug 2019 13:14:47 +0100 |
parents | 129ea1e6d783 |
children |
rev | line source |
---|---|
Chris@17 | 1 <?php |
Chris@17 | 2 /** |
Chris@17 | 3 * \Drupal\Sniffs\Arrays\DisallowLongArraySyntaxSniff. |
Chris@17 | 4 * |
Chris@17 | 5 * @category PHP |
Chris@17 | 6 * @package PHP_CodeSniffer |
Chris@17 | 7 * @link http://pear.php.net/package/PHP_CodeSniffer |
Chris@17 | 8 */ |
Chris@17 | 9 |
Chris@17 | 10 namespace Drupal\Sniffs\Arrays; |
Chris@17 | 11 |
Chris@17 | 12 require_once __DIR__.'/../../../DrupalPractice/Project.php'; |
Chris@17 | 13 |
Chris@17 | 14 use PHP_CodeSniffer\Files\File; |
Chris@17 | 15 use DrupalPractice\Project; |
Chris@17 | 16 use PHP_CodeSniffer\Standards\Generic\Sniffs\Arrays\DisallowLongArraySyntaxSniff as GenericDisallowLongArraySyntaxSniff; |
Chris@17 | 17 |
Chris@17 | 18 /** |
Chris@17 | 19 * Bans the use of the PHP long array syntax in Drupal 8. |
Chris@17 | 20 * |
Chris@17 | 21 * @category PHP |
Chris@17 | 22 * @package PHP_CodeSniffer |
Chris@17 | 23 * @link http://pear.php.net/package/PHP_CodeSniffer |
Chris@17 | 24 */ |
Chris@17 | 25 class DisallowLongArraySyntaxSniff extends GenericDisallowLongArraySyntaxSniff |
Chris@17 | 26 { |
Chris@17 | 27 |
Chris@17 | 28 |
Chris@17 | 29 /** |
Chris@17 | 30 * Processes this test, when one of its tokens is encountered. |
Chris@17 | 31 * |
Chris@17 | 32 * @param \PHP_CodeSniffer\Files\File $phpcsFile The file being scanned. |
Chris@17 | 33 * @param int $stackPtr The position of the current token |
Chris@17 | 34 * in the stack passed in $tokens. |
Chris@17 | 35 * |
Chris@17 | 36 * @return void|int |
Chris@17 | 37 */ |
Chris@17 | 38 public function process(File $phpcsFile, $stackPtr) |
Chris@17 | 39 { |
Chris@17 | 40 $drupalVersion = Project::getCoreVersion($phpcsFile); |
Chris@17 | 41 if ($drupalVersion !== '8.x') { |
Chris@17 | 42 // No need to check this file again, mark it as done. |
Chris@17 | 43 return ($phpcsFile->numTokens + 1); |
Chris@17 | 44 } |
Chris@17 | 45 |
Chris@17 | 46 return parent::process($phpcsFile, $stackPtr); |
Chris@17 | 47 |
Chris@17 | 48 }//end process() |
Chris@17 | 49 |
Chris@17 | 50 |
Chris@17 | 51 }//end class |