diff --git a/src/Standards/Generic/Sniffs/WhiteSpace/DisallowSpaceIndentSniff.php b/src/Standards/Generic/Sniffs/WhiteSpace/DisallowSpaceIndentSniff.php index 4218410acb..e952016a5a 100644 --- a/src/Standards/Generic/Sniffs/WhiteSpace/DisallowSpaceIndentSniff.php +++ b/src/Standards/Generic/Sniffs/WhiteSpace/DisallowSpaceIndentSniff.php @@ -80,6 +80,16 @@ public function process(File $phpcsFile, $stackPtr) continue; } + if ($tokens[$i]['code'] === T_WHITESPACE + && isset($tokens[($i + 1)]) === true + && $tokens[($i + 1)]['line'] !== $tokens[$i]['line'] + ) { + // Blank line, ignore. + // If needed, the Squiz.WhiteSpace.SuperfluousWhitespace sniff can clean up + // superfluous whitespace on the line. + continue; + } + // If tabs are being converted to spaces by the tokeniser, the // original content should be checked instead of the converted content. if (isset($tokens[$i]['orig_content']) === true) { diff --git a/src/Standards/Generic/Tests/WhiteSpace/DisallowSpaceIndentUnitTest.inc b/src/Standards/Generic/Tests/WhiteSpace/DisallowSpaceIndentUnitTest.inc index 3732d94f1d..5da6e608a4 100644 --- a/src/Standards/Generic/Tests/WhiteSpace/DisallowSpaceIndentUnitTest.inc +++ b/src/Standards/Generic/Tests/WhiteSpace/DisallowSpaceIndentUnitTest.inc @@ -68,3 +68,7 @@ $x = 1; echo 'And another one.' echo 'And another one.' echo 'And another one.' + +// The next line has four spaces. This is a specific test case. Do not remove the spaces. + +$bar = 2; diff --git a/src/Standards/Generic/Tests/WhiteSpace/DisallowSpaceIndentUnitTest.inc.fixed b/src/Standards/Generic/Tests/WhiteSpace/DisallowSpaceIndentUnitTest.inc.fixed index e07dd241ad..eb2d0dd809 100644 --- a/src/Standards/Generic/Tests/WhiteSpace/DisallowSpaceIndentUnitTest.inc.fixed +++ b/src/Standards/Generic/Tests/WhiteSpace/DisallowSpaceIndentUnitTest.inc.fixed @@ -68,3 +68,7 @@ $x = 1; echo 'And another one.' echo 'And another one.' echo 'And another one.' + +// The next line has four spaces. This is a specific test case. Do not remove the spaces. + +$bar = 2;