src/Standards/BestIt/Sniffs/Commenting/EmptyLinesDocSniff.php
private function searchEmptyLines(File $phpcsFile, int $searchPosition): void
    {
        $endOfDoc = $phpcsFile->findEndOfStatement($searchPosition);

        do {
            $currentToken = $phpcsFile->getTokens()[$searchPosition];
            $nextTokenPosition = (int) $phpcsFile->findNext(
                [T_DOC_COMMENT_WHITESPACE, T_DOC_COMMENT_STAR],
                $searchPosition + 1,
                $endOfDoc,
                true
            );

            if ($hasToken = ($nextTokenPosition > 0)) {
                $nextToken = $phpcsFile->getTokens()[$nextTokenPosition];
                $hasTooManyLines = ($nextToken['line'] - $currentToken['line']) > 2;

                if ($hasTooManyLines) {
                    $isFixing = $phpcsFile->addFixableError(
                        self::ERROR_EMPTY_LINES_FOUND,
                        $nextTokenPosition,
                        static::CODE_EMPTY_LINES_FOUND
                    );

                    if ($isFixing) {
                        $this->removeUnnecessaryLines($phpcsFile, $nextToken, $currentToken);
                    }
                }

                $phpcsFile->recordMetric(
                    $searchPosition,
                    'DocBlock has too many lines',
                    $hasTooManyLines ? 'yes' : 'no'
                );

                $searchPosition = $nextTokenPosition;
            }
        } while ($hasToken);
    }
private function searchEmptyLines(File $phpcsFile, int $searchPosition): void
    {
        $endOfDoc = $phpcsFile->findEndOfStatement($searchPosition);

        do {
            $currentToken = $phpcsFile->getTokens()[$searchPosition];
            $nextTokenPosition = (int) $phpcsFile->findNext(
                [T_DOC_COMMENT_WHITESPACE, T_DOC_COMMENT_STAR],
                $searchPosition + 1,
                $endOfDoc,
                true
            );

            if ($hasToken = ($nextTokenPosition > 0)) {
                $nextToken = $phpcsFile->getTokens()[$nextTokenPosition];
                $hasTooManyLines = ($nextToken['line'] - $currentToken['line']) > 2;

                if ($hasTooManyLines) {
                    $isFixing = $phpcsFile->addFixableError(
                        self::ERROR_EMPTY_LINES_FOUND,
                        $nextTokenPosition,
                        static::CODE_EMPTY_LINES_FOUND
                    );

                    if ($isFixing) {
                        $this->removeUnnecessaryLines($phpcsFile, $nextToken, $currentToken);
                    }
                }

                $phpcsFile->recordMetric(
                    $searchPosition,
                    'DocBlock has too many lines',
                    $hasTooManyLines ? 'yes' : 'no'
                );

                $searchPosition = $nextTokenPosition;
            }
        } while ($hasToken);
    }
private function searchEmptyLines ( File $ phpcsFile , int $ searchPosition ) : void { $ endOfDoc = $ phpcsFile -> findEndOfStatement ( $ searchPosition ) ; do { $ currentToken = $ phpcsFile -> getTokens ( ) [ $ searchPosition ] ; $ nextTokenPosition = ( int ) $ phpcsFile -> findNext ( [ T_DOC_COMMENT_WHITESPACE , T_DOC_COMMENT_STAR ] , $ searchPosition + 1 , $ endOfDoc , true ) ; if ( $ hasToken = ( $ nextTokenPosition > 0 ) ) { $ nextToken = $ phpcsFile -> getTokens ( ) [ $ nextTokenPosition ] ; $ hasTooManyLines = ( $ nextToken [ 'line' ] - $ currentToken [ 'line' ] ) > 2 ; if ( $ hasTooManyLines ) { $ isFixing = $ phpcsFile -> addFixableError ( self :: ERROR_EMPTY_LINES_FOUND , $ nextTokenPosition , static :: CODE_EMPTY_LINES_FOUND ) ; if ( $ isFixing ) { $ this -> removeUnnecessaryLines ( $ phpcsFile , $ nextToken , $ currentToken ) ; } } $ phpcsFile -> recordMetric ( $ searchPosition , 'DocBlock has too many lines' , $ hasTooManyLines ? 'yes' : 'no' ) ; $ searchPosition = $ nextTokenPosition ; } } while ( $ hasToken ) ; }
Process method for tokens within scope and also outside scope.

@param File $phpcsFile The sniffed file.
@param int $searchPosition

@return void
Process method for tokens within scope and also outside scope .