Skip to content

Commit d28b6d3

Browse files
committed
Another fix for EOL tokens not being checked properly. This time, the indent after a newline was getting in the way of proper pattern checking.
1 parent 811fb22 commit d28b6d3

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

CodeSniffer/Standards/AbstractPatternSniff.php

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -379,8 +379,14 @@ protected function processPattern(
379379
} else if ($pattern[$i]['type'] === 'newline') {
380380
if ($tokens[$stackPtr]['code'] === T_WHITESPACE) {
381381
if ($tokens[$stackPtr]['content'] !== $phpcsFile->eolChar) {
382-
$found = $tokens[$stackPtr]['content'].$found;
383-
$hasError = true;
382+
$found = $tokens[$stackPtr]['content'].$found;
383+
384+
// This may just be an indent that comes after a newline
385+
// so check the token before to make sure. If it is a newline, we
386+
// can ignore the error here.
387+
if ($tokens[($stackPtr - 1)]['content'] !== $phpcsFile->eolChar) {
388+
$hasError = true;
389+
}
384390
} else {
385391
$found = 'EOL'.$found;
386392
}

0 commit comments

Comments
 (0)