function DocCommentSpacingSniff::checkLinesAfterLastContent
1 call to DocCommentSpacingSniff::checkLinesAfterLastContent()
- DocCommentSpacingSniff::process in vendor/
slevomat/ coding-standard/ SlevomatCodingStandard/ Sniffs/ Commenting/ DocCommentSpacingSniff.php - * @phpcsSuppress SlevomatCodingStandard.TypeHints.ParameterTypeHint.MissingNativeTypeHint *
File
-
vendor/
slevomat/ coding-standard/ SlevomatCodingStandard/ Sniffs/ Commenting/ DocCommentSpacingSniff.php, line 720
Class
Namespace
SlevomatCodingStandard\Sniffs\CommentingCode
private function checkLinesAfterLastContent(File $phpcsFile, int $docCommentOpenerPointer, int $docCommentCloserPointer, int $lastContentEndPointer) : void {
$whitespaceAfterLastContent = TokenHelper::getContent($phpcsFile, $lastContentEndPointer + 1, $docCommentCloserPointer);
$linesCountAfterLastContent = max(substr_count($whitespaceAfterLastContent, $phpcsFile->eolChar) - 1, 0);
if ($linesCountAfterLastContent === $this->linesCountAfterLastContent) {
return;
}
$fix = $phpcsFile->addFixableError(sprintf('Expected %d line%s after last content, found %d.', $this->linesCountAfterLastContent, $this->linesCountAfterLastContent === 1 ? '' : 's', $linesCountAfterLastContent), $lastContentEndPointer, self::CODE_INCORRECT_LINES_COUNT_AFTER_LAST_CONTENT);
if (!$fix) {
return;
}
$indentation = IndentationHelper::getIndentation($phpcsFile, $docCommentOpenerPointer);
$phpcsFile->fixer
->beginChangeset();
FixerHelper::removeBetween($phpcsFile, $lastContentEndPointer, $docCommentCloserPointer);
$phpcsFile->fixer
->addNewline($lastContentEndPointer);
for ($i = 1; $i <= $this->linesCountAfterLastContent; $i++) {
$phpcsFile->fixer
->addContent($lastContentEndPointer, sprintf('%s *%s', $indentation, $phpcsFile->eolChar));
}
$phpcsFile->fixer
->addContentBefore($docCommentCloserPointer, $indentation . ' ');
$phpcsFile->fixer
->endChangeset();
}