<?php

class ONGR_Sniffs_WhiteSpace_NamespaceSpacingSniff implements PHP_CodeSniffer_Sniff
{


    /**
     * Returns an array of tokens this test wants to listen for.
     *
     * @return array
     */
    public function register()
    {
        return [T_NAMESPACE];
    }

    /**
     * Processes this test, when one of its tokens is encountered.
     *
     * @param PHP_CodeSniffer_File $phpcsFile The file being scanned.
     * @param int                  $stackPtr  The position of the current token
     *                                        in the stack passed in $tokens.
     *
     * @return void
     */
    public function process(PHP_CodeSniffer_File $phpcsFile, $stackPtr)
    {
        $tokens = $phpcsFile->getTokens();
        $content = $phpcsFile->findNext(T_SEMICOLON, $stackPtr) + 1;

        while ($tokens[$content]['code'] == T_WHITESPACE) {
            ++$content;
        }
        var_dump($tokens[$content], $tokens[$stackPtr]);
        if (($tokens[$content]['line'] - $tokens[$stackPtr]['line']) > 2) {
            // Case for minimum lines is written somewhere else.
            $phpcsFile->addError(
                'There must be exactly 1 blank line after namespace declaration',
                $stackPtr,
                'NamespaceSpacing'
            );
        }
    }
}

Check for to many lines after namespace declaration.
Check for to many lines after namespace declaration.
