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