Skip to content

Generic.WhiteSpaceDisallowSpaceIndent fixer bug when line only contains superfluous whitespace #1702

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Original file line number Diff line number Diff line change
Expand Up @@ -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;