Skip to content

Commit

Permalink
ArrayIndentFixer - Don't indent empty lines
Browse files Browse the repository at this point in the history
  • Loading branch information
dmvdbrugge authored and SpacePossum committed Jul 10, 2018
1 parent dcc87d5 commit 480fdcf
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/Fixer/Whitespace/ArrayIndentationFixer.php
Expand Up @@ -80,7 +80,7 @@ protected function applyFix(\SplFileInfo $file, Tokens $tokens)
$token = $tokens[$index];
if ($this->newlineIsInArrayScope($tokens, $index, $array)) {
$content = Preg::replace(
'/(\R)[\t ]*$/',
'/(\R+)[\t ]*$/',
'$1'.$arrayIndent.str_repeat($this->whitespacesConfig->getIndent(), $currentIndentLevel),
$token->getContent()
);
Expand Down
20 changes: 20 additions & 0 deletions tests/Fixer/Whitespace/ArrayIndentationFixerTest.php
Expand Up @@ -701,6 +701,26 @@ class="link"
Link text
</a>
</div>
INPUT
,
],
[
<<<'EXPECTED'
<?php
$arr = [
'a' => 'b',
// 'c' => 'd',
];
EXPECTED
,
<<<'INPUT'
<?php
$arr = [
'a' => 'b',
// 'c' => 'd',
];
INPUT
,
],
Expand Down

0 comments on commit 480fdcf

Please sign in to comment.