src/Standards/BestIt/CodeSniffer/Helper/DocDescriptionHelper.php
public function checkCommentDescription(bool $descriptionRequired): void
    {
        $this->descriptionRequired = $descriptionRequired;

        $commentStartToken = $this->docHelper->getBlockStartToken();
        $commentEndToken = $this->docHelper->getBlockEndToken();

        $summaryPtr = $this->summaryHelper->getCommentSummaryPosition();

        if ($summaryPtr === -1) {
            return;
        }

        $hasTags = count($commentStartToken['comment_tags']) > 0;

        $descriptionStartPtr = $this->getCommentDescriptionStartPointer();

        if ($descriptionStartPtr === -1) {
            $this->addDescriptionNotFoundError($summaryPtr);

            return;
        }

        $descriptionEndPtr = $this->getCommentDescriptionEndPointer();
        $descEndToken = $this->tokens[$descriptionEndPtr];

        $this->checkCommentDescriptionUcFirst($descriptionStartPtr);

        //Fix no or too much lines after description.
        $toLine = $commentEndToken['line'];
        $expectedLines = 0;

        if ($hasTags) {
            $firstTagPtr = array_shift($commentStartToken['comment_tags']);
            $firstTagToken = $this->tokens[$firstTagPtr];
            $toLine = $firstTagToken['line'];

            $expectedLines = 1;
        }

        $diffLines = $toLine - $descEndToken['line'] - 1;

        if ($diffLines === $expectedLines) {
            return;
        }

        if ($diffLines < $expectedLines && $hasTags) {
            $fixNoLine = $this->file->addFixableError(
                AbstractDocSniff::MESSAGE_NO_LINE_AFTER_DESCRIPTION,
                $descriptionEndPtr,
                AbstractDocSniff::CODE_NO_LINE_AFTER_DESCRIPTION
            );

            if ($fixNoLine) {
                $this->fixNoLineAfterDescription();
            }

            return;
        }

        $fixMuchLines = $this->file->addFixableError(
            AbstractDocSniff::MESSAGE_MUCH_LINES_AFTER_DESCRIPTION,
            $descriptionEndPtr,
            AbstractDocSniff::CODE_MUCH_LINES_AFTER_DESCRIPTION
        );

        if ($fixMuchLines) {
            $this->fixMuchLinesAfterDescription($descEndToken['line'] + 1, $toLine - 1);
        }
    }
public function checkCommentDescription(bool $descriptionRequired): void
    {
        $this->descriptionRequired = $descriptionRequired;

        $commentStartToken = $this->docHelper->getBlockStartToken();
        $commentEndToken = $this->docHelper->getBlockEndToken();

        $summaryPtr = $this->summaryHelper->getCommentSummaryPosition();

        if ($summaryPtr === -1) {
            return;
        }

        $hasTags = count($commentStartToken['comment_tags']) > 0;

        $descriptionStartPtr = $this->getCommentDescriptionStartPointer();

        if ($descriptionStartPtr === -1) {
            $this->addDescriptionNotFoundError($summaryPtr);

            return;
        }

        $descriptionEndPtr = $this->getCommentDescriptionEndPointer();
        $descEndToken = $this->tokens[$descriptionEndPtr];

        $this->checkCommentDescriptionUcFirst($descriptionStartPtr);

        //Fix no or too much lines after description.
        $toLine = $commentEndToken['line'];
        $expectedLines = 0;

        if ($hasTags) {
            $firstTagPtr = array_shift($commentStartToken['comment_tags']);
            $firstTagToken = $this->tokens[$firstTagPtr];
            $toLine = $firstTagToken['line'];

            $expectedLines = 1;
        }

        $diffLines = $toLine - $descEndToken['line'] - 1;

        if ($diffLines === $expectedLines) {
            return;
        }

        if ($diffLines < $expectedLines && $hasTags) {
            $fixNoLine = $this->file->addFixableError(
                AbstractDocSniff::MESSAGE_NO_LINE_AFTER_DESCRIPTION,
                $descriptionEndPtr,
                AbstractDocSniff::CODE_NO_LINE_AFTER_DESCRIPTION
            );

            if ($fixNoLine) {
                $this->fixNoLineAfterDescription();
            }

            return;
        }

        $fixMuchLines = $this->file->addFixableError(
            AbstractDocSniff::MESSAGE_MUCH_LINES_AFTER_DESCRIPTION,
            $descriptionEndPtr,
            AbstractDocSniff::CODE_MUCH_LINES_AFTER_DESCRIPTION
        );

        if ($fixMuchLines) {
            $this->fixMuchLinesAfterDescription($descEndToken['line'] + 1, $toLine - 1);
        }
    }
public function checkCommentDescription ( bool $ descriptionRequired ) : void { $ this -> descriptionRequired = $ descriptionRequired ; $ commentStartToken = $ this -> docHelper -> getBlockStartToken ( ) ; $ commentEndToken = $ this -> docHelper -> getBlockEndToken ( ) ; $ summaryPtr = $ this -> summaryHelper -> getCommentSummaryPosition ( ) ; if ( $ summaryPtr === - 1 ) { return ; } $ hasTags = count ( $ commentStartToken [ 'comment_tags' ] ) > 0 ; $ descriptionStartPtr = $ this -> getCommentDescriptionStartPointer ( ) ; if ( $ descriptionStartPtr === - 1 ) { $ this -> addDescriptionNotFoundError ( $ summaryPtr ) ; return ; } $ descriptionEndPtr = $ this -> getCommentDescriptionEndPointer ( ) ; $ descEndToken = $ this -> tokens [ $ descriptionEndPtr ] ; $ this -> checkCommentDescriptionUcFirst ( $ descriptionStartPtr ) ; //Fix no or too much lines after description. $ toLine = $ commentEndToken [ 'line' ] ; $ expectedLines = 0 ; if ( $ hasTags ) { $ firstTagPtr = array_shift ( $ commentStartToken [ 'comment_tags' ] ) ; $ firstTagToken = $ this -> tokens [ $ firstTagPtr ] ; $ toLine = $ firstTagToken [ 'line' ] ; $ expectedLines = 1 ; } $ diffLines = $ toLine - $ descEndToken [ 'line' ] - 1 ; if ( $ diffLines === $ expectedLines ) { return ; } if ( $ diffLines < $ expectedLines && $ hasTags ) { $ fixNoLine = $ this -> file -> addFixableError ( AbstractDocSniff :: MESSAGE_NO_LINE_AFTER_DESCRIPTION , $ descriptionEndPtr , AbstractDocSniff :: CODE_NO_LINE_AFTER_DESCRIPTION ) ; if ( $ fixNoLine ) { $ this -> fixNoLineAfterDescription ( ) ; } return ; } $ fixMuchLines = $ this -> file -> addFixableError ( AbstractDocSniff :: MESSAGE_MUCH_LINES_AFTER_DESCRIPTION , $ descriptionEndPtr , AbstractDocSniff :: CODE_MUCH_LINES_AFTER_DESCRIPTION ) ; if ( $ fixMuchLines ) { $ this -> fixMuchLinesAfterDescription ( $ descEndToken [ 'line' ] + 1 , $ toLine - 1 ) ; } }
Checks for comment description.

@param bool $descriptionRequired Indicator if the description is required.

@return void
Checks for comment description .