comparison vendor/drupal/coder/coder_sniffer/Drupal/Sniffs/InfoFiles/DuplicateEntrySniff.php @ 17:129ea1e6d783

Update, including to Drupal core 8.6.10
author Chris Cannam
date Thu, 28 Feb 2019 13:21:36 +0000
parents 4c8ae668cc8c
children
comparison
equal deleted inserted replaced
16:c2387f117808 17:129ea1e6d783
1 <?php 1 <?php
2 /** 2 /**
3 * Drupal_Sniffs_InfoFiles_DuplicateEntrySniff. 3 * \Drupal\Sniffs\InfoFiles\DuplicateEntrySniff.
4 * 4 *
5 * @category PHP 5 * @category PHP
6 * @package PHP_CodeSniffer 6 * @package PHP_CodeSniffer
7 * @link http://pear.php.net/package/PHP_CodeSniffer 7 * @link http://pear.php.net/package/PHP_CodeSniffer
8 */ 8 */
9
10 namespace Drupal\Sniffs\InfoFiles;
11
12 use PHP_CodeSniffer\Files\File;
13 use PHP_CodeSniffer\Sniffs\Sniff;
9 14
10 /** 15 /**
11 * Make sure that entries in info files are specified only once. 16 * Make sure that entries in info files are specified only once.
12 * 17 *
13 * @category PHP 18 * @category PHP
14 * @package PHP_CodeSniffer 19 * @package PHP_CodeSniffer
15 * @link http://pear.php.net/package/PHP_CodeSniffer 20 * @link http://pear.php.net/package/PHP_CodeSniffer
16 */ 21 */
17 class Drupal_Sniffs_InfoFiles_DuplicateEntrySniff implements PHP_CodeSniffer_Sniff 22 class DuplicateEntrySniff implements Sniff
18 { 23 {
19 24
20 25
21 /** 26 /**
22 * Returns an array of tokens this test wants to listen for. 27 * Returns an array of tokens this test wants to listen for.
31 36
32 37
33 /** 38 /**
34 * Processes this test, when one of its tokens is encountered. 39 * Processes this test, when one of its tokens is encountered.
35 * 40 *
36 * @param PHP_CodeSniffer_File $phpcsFile The file being scanned. 41 * @param \PHP_CodeSniffer\Files\File $phpcsFile The file being scanned.
37 * @param int $stackPtr The position of the current token in the 42 * @param int $stackPtr The position of the current token in the
38 * stack passed in $tokens. 43 * stack passed in $tokens.
39 * 44 *
40 * @return int 45 * @return int
41 */ 46 */
42 public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr) 47 public function process(File $phpcsFile, $stackPtr)
43 { 48 {
44 // Only run this sniff once per info file. 49 // Only run this sniff once per info file.
45 $fileExtension = strtolower(substr($phpcsFile->getFilename(), -4)); 50 $fileExtension = strtolower(substr($phpcsFile->getFilename(), -4));
46 if ($fileExtension !== 'info') { 51 if ($fileExtension !== 'info') {
47 return ($phpcsFile->numTokens + 1); 52 return ($phpcsFile->numTokens + 1);