diff --git a/src/Fixer/Whitespace/ArrayIndentationFixer.php b/src/Fixer/Whitespace/ArrayIndentationFixer.php index 39087263ceb..a6ef96e8e4b 100644 --- a/src/Fixer/Whitespace/ArrayIndentationFixer.php +++ b/src/Fixer/Whitespace/ArrayIndentationFixer.php @@ -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() ); diff --git a/tests/Fixer/Whitespace/ArrayIndentationFixerTest.php b/tests/Fixer/Whitespace/ArrayIndentationFixerTest.php index 806eb62c7a2..050e1e457a1 100644 --- a/tests/Fixer/Whitespace/ArrayIndentationFixerTest.php +++ b/tests/Fixer/Whitespace/ArrayIndentationFixerTest.php @@ -701,6 +701,26 @@ class="link" Link text +INPUT + , + ], + [ + <<<'EXPECTED' + 'b', + + // 'c' => 'd', +]; +EXPECTED + , + <<<'INPUT' + 'b', + +// 'c' => 'd', +]; INPUT , ],