function DocCommentHelper::getDocCommentDescription
*
Return value
list<Comment>|null
2 calls to DocCommentHelper::getDocCommentDescription()
- DocCommentHelper::hasDocCommentDescription in vendor/
slevomat/ coding-standard/ SlevomatCodingStandard/ Helpers/ DocCommentHelper.php - ForbiddenCommentsSniff::process in vendor/
slevomat/ coding-standard/ SlevomatCodingStandard/ Sniffs/ Commenting/ ForbiddenCommentsSniff.php - * @phpcsSuppress SlevomatCodingStandard.TypeHints.ParameterTypeHint.MissingNativeTypeHint *
File
-
vendor/
slevomat/ coding-standard/ SlevomatCodingStandard/ Helpers/ DocCommentHelper.php, line 75
Class
- DocCommentHelper
- @internal
Namespace
SlevomatCodingStandard\HelpersCode
public static function getDocCommentDescription(File $phpcsFile, int $pointer) : ?array {
$docCommentOpenPointer = self::findDocCommentOpenPointer($phpcsFile, $pointer);
if ($docCommentOpenPointer === null) {
return null;
}
$tokens = $phpcsFile->getTokens();
$descriptionStartPointer = TokenHelper::findNextExcluding($phpcsFile, [
T_DOC_COMMENT_WHITESPACE,
T_DOC_COMMENT_STAR,
], $docCommentOpenPointer + 1, $tokens[$docCommentOpenPointer]['comment_closer']);
if ($descriptionStartPointer === null) {
return null;
}
if ($tokens[$descriptionStartPointer]['code'] !== T_DOC_COMMENT_STRING) {
return null;
}
$tokenAfterDescriptionPointer = TokenHelper::findNext($phpcsFile, [
T_DOC_COMMENT_TAG,
T_DOC_COMMENT_CLOSE_TAG,
], $descriptionStartPointer + 1, $tokens[$docCommentOpenPointer]['comment_closer'] + 1);
/** @var list<Comment> $comments */
$comments = [];
for ($i = $descriptionStartPointer; $i < $tokenAfterDescriptionPointer; $i++) {
if ($tokens[$i]['code'] !== T_DOC_COMMENT_STRING) {
continue;
}
$comments[] = new Comment($i, trim($tokens[$i]['content']));
}
return count($comments) > 0 ? $comments : null;
}