src/Standards/BestIt/Sniffs/DocTags/TagSortingSniff.php
private function checkAndRegisterLineBreakErrors(): void
    {
        $tokens = $this->getTagTokens();
        $prevToken = [];
        $tagCounts = $this->docTagHelper->getTagCounts($tokens);
        $withReturn = false;

        foreach ($tokens as $tokenPos => $token) {
            $thisTagContent = $token['content'];
            $isReturn = $thisTagContent === '@return';

            $isGroupSwitch =
                // Did we switch the tag ...
                $prevToken && ($prevToken['content'] !== $thisTagContent) &&
                // ... but do we skip singles or are we entering the return block which should contain only 1 tag.
                (($tagCounts[$thisTagContent] !== 1) || ($isReturn && !$withReturn));

            // Insert new line between groups or before the return tag if there is no line break already.
            if ($isGroupSwitch && (($prevToken['line'] + 1) === $token['line'])) {
                $isFixing = $this->file->addFixableWarning(
                    static::MESSAGE_MISSING_NEWLINE_BETWEEN_TAGS,
                    $tokenPos,
                    static::CODE_MISSING_NEWLINE_BETWEEN_TAGS,
                    [
                        $prevToken['content']
                    ]
                );

                if ($isFixing) {
                    $this->insertNewLine($token);
                }
            }

            $prevToken = $token;
            // Return should be the last element, so this is ok.
            $withReturn = $isReturn;
        }
    }
private function checkAndRegisterLineBreakErrors(): void
    {
        $tokens = $this->getTagTokens();
        $prevToken = [];
        $tagCounts = $this->docTagHelper->getTagCounts($tokens);
        $withReturn = false;

        foreach ($tokens as $tokenPos => $token) {
            $thisTagContent = $token['content'];
            $isReturn = $thisTagContent === '@return';

            $isGroupSwitch =
                // Did we switch the tag ...
                $prevToken && ($prevToken['content'] !== $thisTagContent) &&
                // ... but do we skip singles or are we entering the return block which should contain only 1 tag.
                (($tagCounts[$thisTagContent] !== 1) || ($isReturn && !$withReturn));

            // Insert new line between groups or before the return tag if there is no line break already.
            if ($isGroupSwitch && (($prevToken['line'] + 1) === $token['line'])) {
                $isFixing = $this->file->addFixableWarning(
                    static::MESSAGE_MISSING_NEWLINE_BETWEEN_TAGS,
                    $tokenPos,
                    static::CODE_MISSING_NEWLINE_BETWEEN_TAGS,
                    [
                        $prevToken['content']
                    ]
                );

                if ($isFixing) {
                    $this->insertNewLine($token);
                }
            }

            $prevToken = $token;
            // Return should be the last element, so this is ok.
            $withReturn = $isReturn;
        }
    }
private function checkAndRegisterLineBreakErrors ( ) : void { $ tokens = $ this -> getTagTokens ( ) ; $ prevToken = [ ] ; $ tagCounts = $ this -> docTagHelper -> getTagCounts ( $ tokens ) ; $ withReturn = false ; foreach ( $ tokens as $ tokenPos => $ token ) { $ thisTagContent = $ token [ 'content' ] ; $ isReturn = $ thisTagContent === '@return' ; $ isGroupSwitch = // Did we switch the tag ... $ prevToken && ( $ prevToken [ 'content' ] !== $ thisTagContent ) && // ... but do we skip singles or are we entering the return block which should contain only 1 tag. ( ( $ tagCounts [ $ thisTagContent ] !== 1 ) || ( $ isReturn && ! $ withReturn ) ) ; // Insert new line between groups or before the return tag if there is no line break already. if ( $ isGroupSwitch && ( ( $ prevToken [ 'line' ] + 1 ) === $ token [ 'line' ] ) ) { $ isFixing = $ this -> file -> addFixableWarning ( static :: MESSAGE_MISSING_NEWLINE_BETWEEN_TAGS , $ tokenPos , static :: CODE_MISSING_NEWLINE_BETWEEN_TAGS , [ $ prevToken [ 'content' ] ] ) ; if ( $ isFixing ) { $ this -> insertNewLine ( $ token ) ; } } $ prevToken = $ token ; // Return should be the last element, so this is ok. $ withReturn = $ isReturn ; } }
Checks for line break errors and registers the errors if there are any.

This should be called after the sorting is already checked and fixed!

@return void
Checks for line break errors and registers the errors if there are any .