You are here

public function Drupal_Sniffs_WhiteSpace_EmptyLinesSniff::process in Coder 7.2

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

Parameters

PHP_CodeSniffer_File $phpcsFile The file being scanned.:

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

Return value

void

File

coder_sniffer/Drupal/Sniffs/WhiteSpace/EmptyLinesSniff.php, line 59

Class

Drupal_Sniffs_WhiteSpace_EmptyLinesSniff
Drupal_Sniffs_WhiteSpace_EmptyLinesSniff.

Code

public function process(PHP_CodeSniffer_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');
  }
}