diff --git a/src/Fixer/Import/SingleLineAfterImportsFixer.php b/src/Fixer/Import/SingleLineAfterImportsFixer.php index 739ab7ed0b2..b32fca3e5eb 100644 --- a/src/Fixer/Import/SingleLineAfterImportsFixer.php +++ b/src/Fixer/Import/SingleLineAfterImportsFixer.php @@ -137,6 +137,9 @@ protected function applyFix(\SplFileInfo $file, Tokens $tokens) if ($tokens[$insertIndex]->isWhitespace()) { $nextToken = $tokens[$insertIndex]; + if (2 === substr_count($nextToken->getContent(), "\n")) { + continue; + } $nextMeaningfulAfterUseIndex = $tokens->getNextMeaningfulToken($insertIndex); if (null !== $nextMeaningfulAfterUseIndex && $tokens[$nextMeaningfulAfterUseIndex]->isGivenKind(T_USE)) { if (substr_count($nextToken->getContent(), "\n") < 2) { diff --git a/tests/Fixer/Import/SingleLineAfterImportsFixerTest.php b/tests/Fixer/Import/SingleLineAfterImportsFixerTest.php index c8cc8d68d70..fe9ed3f7086 100644 --- a/tests/Fixer/Import/SingleLineAfterImportsFixerTest.php +++ b/tests/Fixer/Import/SingleLineAfterImportsFixerTest.php @@ -436,6 +436,13 @@ class Test {} use some\a\ClassA; use function some\a\fn_a; use const some\c; ', ], + [ + str_replace("\n", "\r\n", '