public function EmptyLinesSniff::process in Coder 8.2
Same name and namespace in other branches
- 8.3 coder_sniffer/Drupal/Sniffs/WhiteSpace/EmptyLinesSniff.php \Drupal\Sniffs\WhiteSpace\EmptyLinesSniff::process()
- 8.3.x coder_sniffer/Drupal/Sniffs/WhiteSpace/EmptyLinesSniff.php \Drupal\Sniffs\WhiteSpace\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
File
- coder_sniffer/
Drupal/ Sniffs/ WhiteSpace/ EmptyLinesSniff.php, line 60
Class
Namespace
Drupal\Sniffs\WhiteSpaceCode
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');
}
}