protected function assertNewLineAtTheBeginning(File $phpCsFile, int $stackPointer): void
    {
        $tokens = $phpCsFile->getTokens();

        $line = $tokens[$stackPointer]['line'];
        $firstTokenInLineIndex = $stackPointer;
        while ($tokens[$firstTokenInLineIndex - 1]['line'] === $line) {
            $firstTokenInLineIndex--;
        }

        $prevContentIndex = $phpCsFile->findPrevious(T_WHITESPACE, $firstTokenInLineIndex - 1, null, true);
        if ($tokens[$prevContentIndex]['type'] === 'T_DOC_COMMENT_CLOSE_TAG') {
            $firstTokenInLineIndex = $tokens[$prevContentIndex]['comment_opener'];
            while ($tokens[$firstTokenInLineIndex - 1]['line'] === $line) {
                $firstTokenInLineIndex--;
            }
        }

        $prevContentIndex = $phpCsFile->findPrevious(T_WHITESPACE, $firstTokenInLineIndex - 1, null, true);

        // Do not mess with the start of the class
        if ($tokens[$prevContentIndex]['type'] === 'T_OPEN_CURLY_BRACKET') {
            return;
        }

        if ($tokens[$prevContentIndex]['line'] < $tokens[$firstTokenInLineIndex]['line'] - 1) {
            return;
        }

        $fix = $phpCsFile->addFixableError('Every function/method needs a newline before', $firstTokenInLineIndex, 'Concrete');
        if ($fix) {
            $phpCsFile->fixer->addNewline($prevContentIndex);
        }
    }
protected function assertNewLineAtTheBeginning(File $phpCsFile, int $stackPointer): void
    {
        $tokens = $phpCsFile->getTokens();

        $line = $tokens[$stackPointer]['line'];
        $firstTokenInLineIndex = $stackPointer;
        while ($tokens[$firstTokenInLineIndex - 1]['line'] === $line) {
            $firstTokenInLineIndex--;
        }

        $prevContentIndex = $phpCsFile->findPrevious(T_WHITESPACE, $firstTokenInLineIndex - 1, null, true);
        if ($tokens[$prevContentIndex]['type'] === 'T_DOC_COMMENT_CLOSE_TAG') {
            $firstTokenInLineIndex = $tokens[$prevContentIndex]['comment_opener'];
            while ($tokens[$firstTokenInLineIndex - 1]['line'] === $line) {
                $firstTokenInLineIndex--;
            }
        }

        $prevContentIndex = $phpCsFile->findPrevious(T_WHITESPACE, $firstTokenInLineIndex - 1, null, true);

        // Do not mess with the start of the class
        if ($tokens[$prevContentIndex]['type'] === 'T_OPEN_CURLY_BRACKET') {
            return;
        }

        if ($tokens[$prevContentIndex]['line'] < $tokens[$firstTokenInLineIndex]['line'] - 1) {
            return;
        }

        $fix = $phpCsFile->addFixableError('Every function/method needs a newline before', $firstTokenInLineIndex, 'Concrete');
        if ($fix) {
            $phpCsFile->fixer->addNewline($prevContentIndex);
        }
    }
protected function assertNewLineAtTheBeginning ( File $ phpCsFile , int $ stackPointer ) : void { $ tokens = $ phpCsFile -> getTokens ( ) ; $ line = $ tokens [ $ stackPointer ] [ 'line' ] ; $ firstTokenInLineIndex = $ stackPointer ; while ( $ tokens [ $ firstTokenInLineIndex - 1 ] [ 'line' ] === $ line ) { $ firstTokenInLineIndex -- ; } $ prevContentIndex = $ phpCsFile -> findPrevious ( T_WHITESPACE , $ firstTokenInLineIndex - 1 , null , true ) ; if ( $ tokens [ $ prevContentIndex ] [ 'type' ] === 'T_DOC_COMMENT_CLOSE_TAG' ) { $ firstTokenInLineIndex = $ tokens [ $ prevContentIndex ] [ 'comment_opener' ] ; while ( $ tokens [ $ firstTokenInLineIndex - 1 ] [ 'line' ] === $ line ) { $ firstTokenInLineIndex -- ; } } $ prevContentIndex = $ phpCsFile -> findPrevious ( T_WHITESPACE , $ firstTokenInLineIndex - 1 , null , true ) ; // Do not mess with the start of the class if ( $ tokens [ $ prevContentIndex ] [ 'type' ] === 'T_OPEN_CURLY_BRACKET' ) { return ; } if ( $ tokens [ $ prevContentIndex ] [ 'line' ] < $ tokens [ $ firstTokenInLineIndex ] [ 'line' ] - 1 ) { return ; } $ fix = $ phpCsFile -> addFixableError ( 'Every function/method needs a newline before' , $ firstTokenInLineIndex , 'Concrete' ) ; if ( $ fix ) { $ phpCsFile -> fixer -> addNewline ( $ prevContentIndex ) ; } }
Asserts newline at the beginning, including the doc block.

@param \PHP_CodeSniffer\Files\File $phpCsFile
@param int $stackPointer

@return void
Asserts newline at the beginning including the doc block .