Mercurial > hg > isophonics-drupal-site
comparison vendor/drupal/coder/coder_sniffer/Drupal/Sniffs/Semantics/TInHookMenuSniff.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_Semanitcs_TInHookMenuSniff. | 3 * \Drupal\Sniffs\Semantics\TInHookMenuSniff. |
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\Semantics; | |
11 | |
12 use PHP_CodeSniffer\Files\File; | |
13 use PHP_CodeSniffer\Util\Tokens; | |
9 | 14 |
10 /** | 15 /** |
11 * Checks that t() is not used in hook_menu(). | 16 * Checks that t() is not used in hook_menu(). |
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_Semantics_TInHookMenuSniff extends Drupal_Sniffs_Semantics_FunctionDefinition | 22 class TInHookMenuSniff extends FunctionDefinition |
18 { | 23 { |
19 | 24 |
20 | 25 |
21 /** | 26 /** |
22 * Process this function definition. | 27 * Process this function definition. |
23 * | 28 * |
24 * @param PHP_CodeSniffer_File $phpcsFile The file being scanned. | 29 * @param \PHP_CodeSniffer\Files\File $phpcsFile The file being scanned. |
25 * @param int $stackPtr The position of the function name in the stack. | 30 * @param int $stackPtr The position of the function name in the stack. |
26 * name in the stack. | 31 * name in the stack. |
27 * @param int $functionPtr The position of the function keyword in the stack. | 32 * @param int $functionPtr The position of the function keyword in the stack. |
28 * keyword in the stack. | 33 * keyword in the stack. |
29 * | 34 * |
30 * @return void | 35 * @return void |
31 */ | 36 */ |
32 public function processFunction(PHP_CodeSniffer_File $phpcsFile, $stackPtr, $functionPtr) | 37 public function processFunction(File $phpcsFile, $stackPtr, $functionPtr) |
33 { | 38 { |
34 $fileExtension = strtolower(substr($phpcsFile->getFilename(), -6)); | 39 $fileExtension = strtolower(substr($phpcsFile->getFilename(), -6)); |
35 // Only check in *.module files. | 40 // Only check in *.module files. |
36 if ($fileExtension !== 'module') { | 41 if ($fileExtension !== 'module') { |
37 return; | 42 return; |
50 $tokens[$functionPtr]['scope_closer'] | 55 $tokens[$functionPtr]['scope_closer'] |
51 ); | 56 ); |
52 while ($string !== false) { | 57 while ($string !== false) { |
53 if ($tokens[$string]['content'] === 't') { | 58 if ($tokens[$string]['content'] === 't') { |
54 $opener = $phpcsFile->findNext( | 59 $opener = $phpcsFile->findNext( |
55 PHP_CodeSniffer_Tokens::$emptyTokens, | 60 Tokens::$emptyTokens, |
56 ($string + 1), | 61 ($string + 1), |
57 null, | 62 null, |
58 true | 63 true |
59 ); | 64 ); |
60 if ($opener !== false | 65 if ($opener !== false |