| @@ 126-144 (lines=19) @@ | ||
| 123 | } |
|
| 124 | ||
| 125 | // No extra newline before short description. |
|
| 126 | if ($tokens[$short]['line'] !== ($tokens[$stackPtr]['line'] + 1)) { |
|
| 127 | $error = 'Doc comment short description must be on the first line'; |
|
| 128 | $fix = $phpcsFile->addFixableError($error, $short, 'SpacingBeforeShort'); |
|
| 129 | if ($fix === true) { |
|
| 130 | $phpcsFile->fixer->beginChangeset(); |
|
| 131 | for ($i = $stackPtr; $i < $short; $i++) { |
|
| 132 | if ($tokens[$i]['line'] === $tokens[$stackPtr]['line']) { |
|
| 133 | continue; |
|
| 134 | } |
|
| 135 | if ($tokens[$i]['line'] === $tokens[$short]['line']) { |
|
| 136 | break; |
|
| 137 | } |
|
| 138 | ||
| 139 | $phpcsFile->fixer->replaceToken($i, ''); |
|
| 140 | } |
|
| 141 | ||
| 142 | $phpcsFile->fixer->endChangeset(); |
|
| 143 | } |
|
| 144 | } |
|
| 145 | ||
| 146 | // Account for the fact that a short description might cover |
|
| 147 | // multiple lines. |
|
| @@ 128-145 (lines=18) @@ | ||
| 125 | } |
|
| 126 | ||
| 127 | // No extra newline before short description. |
|
| 128 | if ($tokens[$short]['line'] !== ($tokens[$stackPtr]['line'] + 1)) { |
|
| 129 | $error = 'Doc comment short description must be on the first line'; |
|
| 130 | $fix = $phpcsFile->addFixableError($error, $short, 'SpacingBeforeShort'); |
|
| 131 | if ($fix === true) { |
|
| 132 | $phpcsFile->fixer->beginChangeset(); |
|
| 133 | for ($i = $stackPtr; $i < $short; $i++) { |
|
| 134 | if ($tokens[$i]['line'] === $tokens[$stackPtr]['line']) { |
|
| 135 | continue; |
|
| 136 | } else if ($tokens[$i]['line'] === $tokens[$short]['line']) { |
|
| 137 | break; |
|
| 138 | } |
|
| 139 | ||
| 140 | $phpcsFile->fixer->replaceToken($i, ''); |
|
| 141 | } |
|
| 142 | ||
| 143 | $phpcsFile->fixer->endChangeset(); |
|
| 144 | } |
|
| 145 | } |
|
| 146 | ||
| 147 | // Account for the fact that a short description might cover |
|
| 148 | // multiple lines. |
|
| @@ 169-186 (lines=18) @@ | ||
| 166 | ||
| 167 | $long = $phpcsFile->findNext($empty, ($shortEnd + 1), ($commentEnd - 1), true); |
|
| 168 | if ($long !== false && $tokens[$long]['code'] === T_DOC_COMMENT_STRING) { |
|
| 169 | if ($tokens[$long]['line'] !== ($tokens[$shortEnd]['line'] + 2)) { |
|
| 170 | $error = 'There must be exactly one blank line between descriptions in a doc comment'; |
|
| 171 | $fix = $phpcsFile->addFixableError($error, $long, 'SpacingBetween'); |
|
| 172 | if ($fix === true) { |
|
| 173 | $phpcsFile->fixer->beginChangeset(); |
|
| 174 | for ($i = ($shortEnd + 1); $i < $long; $i++) { |
|
| 175 | if ($tokens[$i]['line'] === $tokens[$shortEnd]['line']) { |
|
| 176 | continue; |
|
| 177 | } else if ($tokens[$i]['line'] === ($tokens[$long]['line'] - 1)) { |
|
| 178 | break; |
|
| 179 | } |
|
| 180 | ||
| 181 | $phpcsFile->fixer->replaceToken($i, ''); |
|
| 182 | } |
|
| 183 | ||
| 184 | $phpcsFile->fixer->endChangeset(); |
|
| 185 | } |
|
| 186 | } |
|
| 187 | ||
| 188 | if (preg_match('/^\p{Ll}/u', $tokens[$long]['content']) === 1) { |
|
| 189 | $error = 'Doc comment long description must start with a capital letter'; |
|