comparison vendor/drupal/coder/coder_sniffer/DrupalPractice/Sniffs/General/LanguageNoneSniff.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 * DrupalPractice_Sniffs_General_LanguageNoneSniff 3 * \DrupalPractice\Sniffs\General\LanguageNoneSniff
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 DrupalPractice\Sniffs\General;
11
12 use PHP_CodeSniffer\Files\File;
13 use PHP_CodeSniffer\Sniffs\Sniff;
9 14
10 /** 15 /**
11 * Checks that ['und'] is not used, should be LANGUAGE_NONE. 16 * Checks that ['und'] is not used, should be LANGUAGE_NONE.
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 DrupalPractice_Sniffs_General_LanguageNoneSniff implements PHP_CodeSniffer_Sniff 22 class LanguageNoneSniff 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.
34 39
35 40
36 /** 41 /**
37 * Processes this test, when one of its tokens is encountered. 42 * Processes this test, when one of its tokens is encountered.
38 * 43 *
39 * @param PHP_CodeSniffer_File $phpcsFile The current file being processed. 44 * @param \PHP_CodeSniffer\Files\File $phpcsFile The file being scanned.
40 * @param int $stackPtr The position of the current token 45 * @param int $stackPtr The position of the function
41 * in the stack passed in $tokens. 46 * name in the stack.
42 * 47 *
43 * @return void 48 * @return void
44 */ 49 */
45 public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr) 50 public function process(File $phpcsFile, $stackPtr)
46 { 51 {
47 $sequence = $phpcsFile->getTokensAsString($stackPtr, 3); 52 $sequence = $phpcsFile->getTokensAsString($stackPtr, 3);
48 if ($sequence === "['und']" || $sequence === '["und"]') { 53 if ($sequence === "['und']" || $sequence === '["und"]') {
49 $warning = "Are you accessing field values here? Then you should use LANGUAGE_NONE instead of 'und'"; 54 $warning = "Are you accessing field values here? Then you should use LANGUAGE_NONE instead of 'und'";
50 $phpcsFile->addWarning($warning, ($stackPtr + 1), 'Und'); 55 $phpcsFile->addWarning($warning, ($stackPtr + 1), 'Und');