Skip to content

Commit

Permalink
bug PHP-CS-Fixer#314 Fix: multiple spaces between 'else' and 'if' not…
Browse files Browse the repository at this point in the history
… fixed (fisharebest)

This PR was merged into the 0.4.x-dev branch.

Discussion
----------

Fix: multiple spaces between 'else' and 'if' not fixed

Multiple spaces between "else" and "if" aren't fixed - just single spaces.

Commits
-------

5148bbc Fix: multiple spaces between 'else' and 'if' not fixed
  • Loading branch information
fabpot committed Mar 3, 2014
2 parents cb2874c + 5148bbc commit fc0d890
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Symfony/CS/Fixer/ElseifFixer.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class ElseifFixer implements FixerInterface
public function fix(\SplFileInfo $file, $content)
{
// [Structure] elseif, not else if
return str_replace('} else if (', '} elseif (', $content);
return preg_replace('/} else +if \(/', '} elseif (', $content);
}

public function getLevel()
Expand Down
5 changes: 5 additions & 0 deletions Symfony/CS/Tests/Fixer/ElseifFixerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,11 @@ public function testThatInvalidElseIfIsFixed()
'if ($some) { $test = true } elseif ($some != "test") { $test = false; }',
$fixer->fix($this->getFileMock(), 'if ($some) { $test = true } else if ($some != "test") { $test = false; }'
));

$this->assertSame(
'if ($some) { $test = true } elseif ($some != "test") { $test = false; }',
$fixer->fix($this->getFileMock(), 'if ($some) { $test = true } else if ($some != "test") { $test = false; }'
));
}

/**
Expand Down

0 comments on commit fc0d890

Please sign in to comment.