Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. DocCommentHelper.php

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\Helpers

Code

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;
}

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal