| @@ 108-123 (lines=16) @@ | ||
| 105 | } |
|
| 106 | ||
| 107 | // Check for additional blank lines at the end of the comment. |
|
| 108 | if ($tokens[$prev]['line'] < ($tokens[$commentEnd]['line'] - 1)) { |
|
| 109 | $error = 'Additional blank lines found at end of doc comment'; |
|
| 110 | $fix = $phpcsFile->addFixableError($error, $commentEnd, 'SpacingAfter'); |
|
| 111 | if ($fix === true) { |
|
| 112 | $phpcsFile->fixer->beginChangeset(); |
|
| 113 | for ($i = ($prev + 1); $i < $commentEnd; $i++) { |
|
| 114 | if ($tokens[($i + 1)]['line'] === $tokens[$commentEnd]['line']) { |
|
| 115 | break; |
|
| 116 | } |
|
| 117 | ||
| 118 | $phpcsFile->fixer->replaceToken($i, ''); |
|
| 119 | } |
|
| 120 | ||
| 121 | $phpcsFile->fixer->endChangeset(); |
|
| 122 | } |
|
| 123 | } |
|
| 124 | ||
| 125 | // No extra newline before short description. |
|
| 126 | if ($tokens[$short]['line'] !== ($tokens[$stackPtr]['line'] + 1)) { |
|
| @@ 103-118 (lines=16) @@ | ||
| 100 | } |
|
| 101 | ||
| 102 | // Check for additional blank lines at the end of the comment. |
|
| 103 | if ($tokens[$prev]['line'] < ($tokens[$commentEnd]['line'] - 1)) { |
|
| 104 | $error = 'Additional blank lines found at end of doc comment'; |
|
| 105 | $fix = $phpcsFile->addFixableError($error, $commentEnd, 'SpacingAfter'); |
|
| 106 | if ($fix === true) { |
|
| 107 | $phpcsFile->fixer->beginChangeset(); |
|
| 108 | for ($i = ($prev + 1); $i < $commentEnd; $i++) { |
|
| 109 | if ($tokens[($i + 1)]['line'] === $tokens[$commentEnd]['line']) { |
|
| 110 | break; |
|
| 111 | } |
|
| 112 | ||
| 113 | $phpcsFile->fixer->replaceToken($i, ''); |
|
| 114 | } |
|
| 115 | ||
| 116 | $phpcsFile->fixer->endChangeset(); |
|
| 117 | } |
|
| 118 | } |
|
| 119 | ||
| 120 | // Check for a comment description. |
|
| 121 | if ($tokens[$short]['code'] !== T_DOC_COMMENT_STRING) { |
|
| @@ 81-98 (lines=18) @@ | ||
| 78 | $prevContent = $phpcsFile->findPrevious(T_WHITESPACE, ($closeBrace - 1), null, true); |
|
| 79 | ||
| 80 | // Special case for empty JS functions. |
|
| 81 | if ($phpcsFile->tokenizerType === 'JS' && $prevContent === $tokens[$stackPtr]['scope_opener']) { |
|
| 82 | // In this case, the opening and closing brace must be |
|
| 83 | // right next to each other. |
|
| 84 | if ($tokens[$stackPtr]['scope_closer'] !== ($tokens[$stackPtr]['scope_opener'] + 1)) { |
|
| 85 | $error = 'The opening and closing braces of empty functions must be directly next to each other; e.g., function () {}'; |
|
| 86 | $fix = $phpcsFile->addFixableError($error, $closeBrace, 'SpacingBetween'); |
|
| 87 | if ($fix === true) { |
|
| 88 | $phpcsFile->fixer->beginChangeset(); |
|
| 89 | for ($i = ($tokens[$stackPtr]['scope_opener'] + 1); $i < $closeBrace; $i++) { |
|
| 90 | $phpcsFile->fixer->replaceToken($i, ''); |
|
| 91 | } |
|
| 92 | ||
| 93 | $phpcsFile->fixer->endChangeset(); |
|
| 94 | } |
|
| 95 | } |
|
| 96 | ||
| 97 | return; |
|
| 98 | } |
|
| 99 | ||
| 100 | $nestedFunction = false; |
|
| 101 | if ($phpcsFile->hasCondition($stackPtr, T_FUNCTION) === true |
|