Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. EmptyLinesSniff.php

function EmptyLinesSniff::process

Processes this test, when one of its tokens is encountered.

Parameters

\PHP_CodeSniffer\Files\File $phpcsFile The file being scanned.:

int $stackPtr The position of the current token: in the stack passed in $tokens.

Return value

void

Overrides Sniff::process

File

vendor/drupal/coder/coder_sniffer/Drupal/Sniffs/WhiteSpace/EmptyLinesSniff.php, line 60

Class

EmptyLinesSniff
\Drupal\Sniffs\WhiteSpace\EmptyLinesSniff.

Namespace

Drupal\Sniffs\WhiteSpace

Code

public function process(File $phpcsFile, $stackPtr) {
    $tokens = $phpcsFile->getTokens();
    if ($tokens[$stackPtr]['content'] === $phpcsFile->eolChar && isset($tokens[$stackPtr + 1]) === true && $tokens[$stackPtr + 1]['content'] === $phpcsFile->eolChar && isset($tokens[$stackPtr + 2]) === true && $tokens[$stackPtr + 2]['content'] === $phpcsFile->eolChar && isset($tokens[$stackPtr + 3]) === true && $tokens[$stackPtr + 3]['content'] === $phpcsFile->eolChar) {
        $error = 'More than 2 empty lines are not allowed';
        $phpcsFile->addError($error, $stackPtr + 3, 'EmptyLines');
    }
}
RSS feed
Powered by Drupal