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