1 | <?php |
||
29 | class DocCommentSniff extends Generic_DocCommentSniff |
||
30 | { |
||
31 | |||
32 | /** |
||
33 | * Processes this test, when one of its tokens is encountered. |
||
34 | * |
||
35 | * @param File $phpcsFile The file being scanned. |
||
36 | * @param int $stackPtr The position of the current token in the |
||
37 | * stack passed in $tokens. |
||
38 | * |
||
39 | * @return void |
||
40 | */ |
||
41 | 1 | public function process(File $phpcsFile, $stackPtr) |
|
42 | { |
||
43 | 1 | $tokens = $phpcsFile->getTokens(); |
|
44 | 1 | $commentEnd = $phpcsFile->findNext(T_DOC_COMMENT_CLOSE_TAG, ($stackPtr + 1)); |
|
45 | 1 | $commentStart = $tokens[$commentEnd]['comment_opener']; |
|
46 | |||
47 | 1 | if ($tokens[$commentStart]['line'] === $tokens[$commentEnd]['line']) { |
|
48 | 1 | $commentText = $phpcsFile->getTokensAsString($commentStart, ($commentEnd - $commentStart + 1)); |
|
49 | |||
50 | 1 | if (strpos($commentText, '@var') !== false || strpos($commentText, '@type') !== false) { |
|
51 | // Skip inline block comments with variable type definition. |
||
52 | 1 | return; |
|
53 | } |
||
54 | 1 | } |
|
55 | |||
56 | 1 | if ($this->isInheritDoc($phpcsFile, $commentStart) === true) { |
|
57 | 1 | return; |
|
58 | } |
||
59 | |||
60 | parent::process($phpcsFile, $stackPtr); |
||
61 | }//end process() |
||
62 | |||
63 | |||
64 | /** |
||
65 | * Is the comment an inheritdoc? |
||
66 | * |
||
67 | * @param File $phpcsFile The file being scanned. |
||
68 | * @param int $commentStart The position in the stack where the comment started. |
||
69 | * |
||
70 | * @return bool |
||
71 | */ |
||
72 | protected function isInheritDoc(File $phpcsFile, $commentStart) |
||
81 | }//end class |
||
82 |