function DocCommentSpacingSniff::process
* @phpcsSuppress SlevomatCodingStandard.TypeHints.ParameterTypeHint.MissingNativeTypeHint *
Parameters
int $docCommentOpenerPointer:
Overrides Sniff::process
File
-
vendor/
slevomat/ coding-standard/ SlevomatCodingStandard/ Sniffs/ Commenting/ DocCommentSpacingSniff.php, line 86
Class
Namespace
SlevomatCodingStandard\Sniffs\CommentingCode
public function process(File $phpcsFile, $docCommentOpenerPointer) : void {
$this->linesCountBeforeFirstContent = SniffSettingsHelper::normalizeInteger($this->linesCountBeforeFirstContent);
$this->linesCountBetweenDescriptionAndAnnotations = SniffSettingsHelper::normalizeInteger($this->linesCountBetweenDescriptionAndAnnotations);
$this->linesCountBetweenDifferentAnnotationsTypes = SniffSettingsHelper::normalizeInteger($this->linesCountBetweenDifferentAnnotationsTypes);
$this->linesCountBetweenAnnotationsGroups = SniffSettingsHelper::normalizeInteger($this->linesCountBetweenAnnotationsGroups);
$this->linesCountAfterLastContent = SniffSettingsHelper::normalizeInteger($this->linesCountAfterLastContent);
if (DocCommentHelper::isInline($phpcsFile, $docCommentOpenerPointer)) {
return;
}
$tokens = $phpcsFile->getTokens();
if (TokenHelper::findNextExcluding($phpcsFile, [
T_DOC_COMMENT_WHITESPACE,
T_DOC_COMMENT_STAR,
], $docCommentOpenerPointer + 1, $tokens[$docCommentOpenerPointer]['comment_closer']) === null) {
return;
}
$parsedDocComment = DocCommentHelper::parseDocComment($phpcsFile, $docCommentOpenerPointer);
if ($parsedDocComment === null) {
return;
}
$firstContentStartPointer = $parsedDocComment->getNodeStartPointer($phpcsFile, $parsedDocComment->getNode()->children[0]);
$firstContentEndPointer = $parsedDocComment->getNodeEndPointer($phpcsFile, $parsedDocComment->getNode()->children[0], $firstContentStartPointer);
$annotations = AnnotationHelper::getAnnotations($phpcsFile, $docCommentOpenerPointer);
usort($annotations, static function (Annotation $a, Annotation $b) : int {
return $a->getStartPointer() <=> $b->getStartPointer();
});
$annotationsCount = count($annotations);
$firstAnnotationPointer = $annotationsCount > 0 ? $annotations[0]->getStartPointer() : null;
/** @var int $lastContentEndPointer */
$lastContentEndPointer = $annotationsCount > 0 ? $annotations[$annotationsCount - 1]->getEndPointer() : $firstContentEndPointer;
$this->checkLinesBeforeFirstContent($phpcsFile, $docCommentOpenerPointer, $firstContentStartPointer);
$this->checkLinesBetweenDescriptionAndFirstAnnotation($phpcsFile, $docCommentOpenerPointer, $firstContentStartPointer, $firstContentEndPointer, $firstAnnotationPointer);
if (count($annotations) > 1) {
if (count($this->getAnnotationsGroups()) === 0) {
$this->checkLinesBetweenDifferentAnnotationsTypes($phpcsFile, $docCommentOpenerPointer, $annotations);
}
else {
$this->checkAnnotationsGroups($phpcsFile, $docCommentOpenerPointer, $annotations);
}
}
$this->checkLinesAfterLastContent($phpcsFile, $docCommentOpenerPointer, $tokens[$docCommentOpenerPointer]['comment_closer'], $lastContentEndPointer);
}