Mercurial > hg > isophonics-drupal-site
comparison vendor/drupal/coder/coder_sniffer/Drupal/Sniffs/Files/EndFileNewlineSniff.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_Files_EndFileNewlineSniff. | 3 * \Drupal\Sniffs\Files\EndFileNewlineSniff. |
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\Files; | |
11 | |
12 use PHP_CodeSniffer\Files\File; | |
13 use PHP_CodeSniffer\Sniffs\Sniff; | |
9 | 14 |
10 /** | 15 /** |
11 * Ensures the file ends with a newline character. | 16 * Ensures the file ends with a newline character. |
12 * | 17 * |
13 * Largely copied from PSR2, but we need to run it on *.txt files and templates as | 18 * Largely copied from PSR2, but we need to run it on *.txt files and templates as |
15 * | 20 * |
16 * @category PHP | 21 * @category PHP |
17 * @package PHP_CodeSniffer | 22 * @package PHP_CodeSniffer |
18 * @link http://pear.php.net/package/PHP_CodeSniffer | 23 * @link http://pear.php.net/package/PHP_CodeSniffer |
19 */ | 24 */ |
20 class Drupal_Sniffs_Files_EndFileNewlineSniff implements PHP_CodeSniffer_Sniff | 25 class EndFileNewlineSniff implements Sniff |
21 { | 26 { |
22 | 27 |
23 | 28 |
24 /** | 29 /** |
25 * A list of tokenizers this sniff supports. | 30 * A list of tokenizers this sniff supports. |
49 | 54 |
50 | 55 |
51 /** | 56 /** |
52 * Processes this sniff, when one of its tokens is encountered. | 57 * Processes this sniff, when one of its tokens is encountered. |
53 * | 58 * |
54 * @param PHP_CodeSniffer_File $phpcsFile The file being scanned. | 59 * @param \PHP_CodeSniffer\Files\File $phpcsFile The file being scanned. |
55 * @param int $stackPtr The position of the current token in | 60 * @param int $stackPtr The position of the current token in |
56 * the stack passed in $tokens. | 61 * the stack passed in $tokens. |
57 * | 62 * |
58 * @return void | 63 * @return void |
59 */ | 64 */ |
60 public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr) | 65 public function process(File $phpcsFile, $stackPtr) |
61 { | 66 { |
62 // Skip to the end of the file. | 67 // Skip to the end of the file. |
63 $tokens = $phpcsFile->getTokens(); | 68 $tokens = $phpcsFile->getTokens(); |
64 if ($phpcsFile->tokenizerType === 'PHP') { | 69 if ($phpcsFile->tokenizerType === 'PHP') { |
65 $lastToken = ($phpcsFile->numTokens - 1); | 70 $lastToken = ($phpcsFile->numTokens - 1); |