Skip to content
This repository was archived by the owner on Nov 5, 2022. It is now read-only.

Commit b6027f3

Browse files
committed
Added newline under file doc comment
1 parent 020a4ff commit b6027f3

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

CodeIgniter4/Sniffs/Commenting/FileCommentSniff.php

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,21 @@ public function process(File $phpcsFile, $stackPtr)
151151
// Check each tag.
152152
$this->processTags($phpcsFile, $stackPtr, $commentStart);
153153

154+
// Check there is 1 empty line after.
155+
$commentCloser = $tokens[$commentStart]['comment_closer'];
156+
$nextContentPtr = $phpcsFile->findNext(T_WHITESPACE, ($commentCloser + 1), null, true);
157+
$lineDiff = ($tokens[$nextContentPtr]['line'] - $tokens[$commentCloser]['line']);
158+
if ($lineDiff === 1) {
159+
$data = array(1);
160+
$error = 'Expected %s empty line after file doc comment';
161+
$fix = $phpcsFile->addFixableError($error, ($commentCloser + 1), 'NoEmptyLineAfterFileDocComment', $data);
162+
if ($fix === true) {
163+
$phpcsFile->fixer->beginChangeset();
164+
$phpcsFile->fixer->addNewlineBefore($nextContentPtr);
165+
$phpcsFile->fixer->endChangeset();
166+
}
167+
}
168+
154169
// Ignore the rest of the file.
155170
return ($phpcsFile->numTokens + 1);
156171

0 commit comments

Comments
 (0)