Skip to content

Commit

Permalink
bug #3887 ArrayIndentFixer - Don't indent empty lines (dmvdbrugge)
Browse files Browse the repository at this point in the history
This PR was squashed before being merged into the 2.12 branch (closes #3887).

Discussion
----------

ArrayIndentFixer - Don't indent empty lines

This fixes #3875

Commits
-------

480fdcf ArrayIndentFixer - Don't indent empty lines
  • Loading branch information
SpacePossum committed Jul 10, 2018
2 parents 758ff3b + 480fdcf commit b63be58
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 b63be58

Please sign in to comment.