Mercurial > hg > isophonics-drupal-site
comparison vendor/drupal/coder/coder_sniffer/Drupal/Sniffs/Classes/UseLeadingBackslashSniff.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_Classes_UseLeadingBackslashSniff. | 3 * \Drupal\Sniffs\Classes\UseLeadingBackslashSniff. |
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\Classes; | |
11 | |
12 use PHP_CodeSniffer\Files\File; | |
13 use PHP_CodeSniffer\Sniffs\Sniff; | |
14 use PHP_CodeSniffer\Util\Tokens; | |
9 | 15 |
10 /** | 16 /** |
11 * Use statements to import classes must not begin with "\". | 17 * Use statements to import classes must not begin with "\". |
12 * | 18 * |
13 * @category PHP | 19 * @category PHP |
14 * @package PHP_CodeSniffer | 20 * @package PHP_CodeSniffer |
15 * @link http://pear.php.net/package/PHP_CodeSniffer | 21 * @link http://pear.php.net/package/PHP_CodeSniffer |
16 */ | 22 */ |
17 class Drupal_Sniffs_Classes_UseLeadingBackslashSniff implements PHP_CodeSniffer_Sniff | 23 class UseLeadingBackslashSniff implements Sniff |
18 { | 24 { |
19 | 25 |
20 | 26 |
21 /** | 27 /** |
22 * Returns an array of tokens this test wants to listen for. | 28 * Returns an array of tokens this test wants to listen for. |
31 | 37 |
32 | 38 |
33 /** | 39 /** |
34 * Processes this test, when one of its tokens is encountered. | 40 * Processes this test, when one of its tokens is encountered. |
35 * | 41 * |
36 * @param PHP_CodeSniffer_File $phpcsFile The file being scanned. | 42 * @param \PHP_CodeSniffer\Files\File $phpcsFile The file being scanned. |
37 * @param int $stackPtr The position of the current token in | 43 * @param int $stackPtr The position of the current token in |
38 * the stack passed in $tokens. | 44 * the stack passed in $tokens. |
39 * | 45 * |
40 * @return void | 46 * @return void |
41 */ | 47 */ |
42 public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr) | 48 public function process(File $phpcsFile, $stackPtr) |
43 { | 49 { |
44 $tokens = $phpcsFile->getTokens(); | 50 $tokens = $phpcsFile->getTokens(); |
45 | 51 |
46 // Only check use statements in the global scope. | 52 // Only check use statements in the global scope. |
47 if (empty($tokens[$stackPtr]['conditions']) === false) { | 53 if (empty($tokens[$stackPtr]['conditions']) === false) { |
48 return; | 54 return; |
49 } | 55 } |
50 | 56 |
51 $startPtr = $phpcsFile->findNext( | 57 $startPtr = $phpcsFile->findNext( |
52 PHP_CodeSniffer_Tokens::$emptyTokens, | 58 Tokens::$emptyTokens, |
53 ($stackPtr + 1), | 59 ($stackPtr + 1), |
54 null, | 60 null, |
55 true | 61 true |
56 ); | 62 ); |
57 | 63 |