comparison vendor/drupal/coder/coder_sniffer/Drupal/Sniffs/Commenting/ClassCommentSniff.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
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\Commenting;
11
12 use PHP_CodeSniffer\Files\File;
13 use PHP_CodeSniffer\Sniffs\Sniff;
14 use PHP_CodeSniffer\Util\Tokens;
15
10 /** 16 /**
11 * Checks that comment doc blocks exist on classes, interfaces and traits. Largely 17 * Checks that comment doc blocks exist on classes, interfaces and traits. Largely
12 * copied from Squiz_Sniffs_Commenting_ClassCommentSniff. 18 * copied from PHP_CodeSniffer\Standards\Squiz\Sniffs\Commenting\ClassCommentSniff.
13 * 19 *
14 * @category PHP 20 * @category PHP
15 * @package PHP_CodeSniffer 21 * @package PHP_CodeSniffer
16 * @author Greg Sherwood <gsherwood@squiz.net> 22 * @author Greg Sherwood <gsherwood@squiz.net>
17 * @copyright 2006-2014 Squiz Pty Ltd (ABN 77 084 670 600) 23 * @copyright 2006-2014 Squiz Pty Ltd (ABN 77 084 670 600)
18 * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence 24 * @license https://github.com/squizlabs/PHP_CodeSniffer/blob/master/licence.txt BSD Licence
19 * @version Release: @package_version@ 25 * @version Release: @package_version@
20 * @link http://pear.php.net/package/PHP_CodeSniffer 26 * @link http://pear.php.net/package/PHP_CodeSniffer
21 */ 27 */
22 class Drupal_Sniffs_Commenting_ClassCommentSniff implements PHP_CodeSniffer_Sniff 28 class ClassCommentSniff implements Sniff
23 { 29 {
24 30
25 31
26 /** 32 /**
27 * Returns an array of tokens this test wants to listen for. 33 * Returns an array of tokens this test wants to listen for.
40 46
41 47
42 /** 48 /**
43 * Processes this test, when one of its tokens is encountered. 49 * Processes this test, when one of its tokens is encountered.
44 * 50 *
45 * @param PHP_CodeSniffer_File $phpcsFile The file being scanned. 51 * @param \PHP_CodeSniffer\Files\File $phpcsFile The file being scanned.
46 * @param int $stackPtr The position of the current token 52 * @param int $stackPtr The position of the current token
47 * in the stack passed in $tokens. 53 * in the stack passed in $tokens.
48 * 54 *
49 * @return void 55 * @return void
50 */ 56 */
51 public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr) 57 public function process(File $phpcsFile, $stackPtr)
52 { 58 {
53 $tokens = $phpcsFile->getTokens(); 59 $tokens = $phpcsFile->getTokens();
54 $find = PHP_CodeSniffer_Tokens::$methodPrefixes; 60 $find = Tokens::$methodPrefixes;
55 $find[] = T_WHITESPACE; 61 $find[] = T_WHITESPACE;
56 $name = $tokens[$stackPtr]['content']; 62 $name = $tokens[$stackPtr]['content'];
57 63
58 $commentEnd = $phpcsFile->findPrevious($find, ($stackPtr - 1), null, true); 64 $commentEnd = $phpcsFile->findPrevious($find, ($stackPtr - 1), null, true);
59 if ($tokens[$commentEnd]['code'] !== T_DOC_COMMENT_CLOSE_TAG 65 if ($tokens[$commentEnd]['code'] !== T_DOC_COMMENT_CLOSE_TAG