comparison vendor/drupal/coder/coder_sniffer/Drupal/Sniffs/WhiteSpace/EmptyLinesSniff.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_WhiteSpace_EmptyLinesSniff. 3 * \Drupal\Sniffs\WhiteSpace\EmptyLinesSniff.
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 9
10 namespace Drupal\Sniffs\WhiteSpace;
11
12 use PHP_CodeSniffer\Files\File;
13 use PHP_CodeSniffer\Sniffs\Sniff;
14
10 /** 15 /**
11 * Drupal_Sniffs_WhiteSpace_EmptyLinesSniff. 16 * \Drupal\Sniffs\WhiteSpace\EmptyLinesSniff.
12 * 17 *
13 * Checks that there are not more than 2 empty lines following each other. 18 * Checks that there are not more than 2 empty lines following each other.
14 * 19 *
15 * @category PHP 20 * @category PHP
16 * @package PHP_CodeSniffer 21 * @package PHP_CodeSniffer
17 * @link http://pear.php.net/package/PHP_CodeSniffer 22 * @link http://pear.php.net/package/PHP_CodeSniffer
18 */ 23 */
19 class Drupal_Sniffs_WhiteSpace_EmptyLinesSniff implements PHP_CodeSniffer_Sniff 24 class EmptyLinesSniff implements Sniff
20 { 25 {
21 26
22 /** 27 /**
23 * A list of tokenizers this sniff supports. 28 * A list of tokenizers this sniff supports.
24 * 29 *
44 49
45 50
46 /** 51 /**
47 * Processes this test, when one of its tokens is encountered. 52 * Processes this test, when one of its tokens is encountered.
48 * 53 *
49 * @param PHP_CodeSniffer_File $phpcsFile The file being scanned. 54 * @param \PHP_CodeSniffer\Files\File $phpcsFile The file being scanned.
50 * @param int $stackPtr The position of the current token 55 * @param int $stackPtr The position of the current token
51 * in the stack passed in $tokens. 56 * in the stack passed in $tokens.
52 * 57 *
53 * @return void 58 * @return void
54 */ 59 */
55 public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr) 60 public function process(File $phpcsFile, $stackPtr)
56 { 61 {
57 $tokens = $phpcsFile->getTokens(); 62 $tokens = $phpcsFile->getTokens();
58 if ($tokens[$stackPtr]['content'] === $phpcsFile->eolChar 63 if ($tokens[$stackPtr]['content'] === $phpcsFile->eolChar
59 && isset($tokens[($stackPtr + 1)]) === true 64 && isset($tokens[($stackPtr + 1)]) === true
60 && $tokens[($stackPtr + 1)]['content'] === $phpcsFile->eolChar 65 && $tokens[($stackPtr + 1)]['content'] === $phpcsFile->eolChar