diff --git a/src/Standards/Squiz/Sniffs/WhiteSpace/ScopeKeywordSpacingSniff.php b/src/Standards/Squiz/Sniffs/WhiteSpace/ScopeKeywordSpacingSniff.php index 9ba69dcf14..abf05dc17e 100644 --- a/src/Standards/Squiz/Sniffs/WhiteSpace/ScopeKeywordSpacingSniff.php +++ b/src/Standards/Squiz/Sniffs/WhiteSpace/ScopeKeywordSpacingSniff.php @@ -44,7 +44,9 @@ public function process(File $phpcsFile, $stackPtr) { $tokens = $phpcsFile->getTokens(); - if (isset($tokens[($stackPtr + 1)]) === false) { + $nextNonWhitespace = $phpcsFile->findNext(T_WHITESPACE, ($stackPtr + 1), null, true); + if ($nextNonWhitespace === false) { + // Parse error/live coding. Bow out. return; } @@ -126,9 +128,6 @@ public function process(File $phpcsFile, $stackPtr) if ($tokens[($stackPtr + 1)]['code'] !== T_WHITESPACE) { $spacing = 0; - } else if (isset($tokens[($stackPtr + 2)]) === false) { - // Parse error/live coding. Bow out. - return; } else { if ($tokens[($stackPtr + 2)]['line'] !== $tokens[$stackPtr]['line']) { $spacing = 'newline';