From 6ab25f075d7b0bc7ed689cd5a092646582990d5f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kuba=20Wer=C5=82os?= Date: Sun, 28 Jun 2020 18:07:11 +0000 Subject: [PATCH] SingleLineAfterImportsFixer - fix for line after import (and before another import) already added using CRLF --- src/Fixer/Import/SingleLineAfterImportsFixer.php | 2 +- .../Import/SingleLineAfterImportsFixerTest.php | 15 ++++++++------- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/src/Fixer/Import/SingleLineAfterImportsFixer.php b/src/Fixer/Import/SingleLineAfterImportsFixer.php index b32fca3e5eb..3d02cda5a94 100644 --- a/src/Fixer/Import/SingleLineAfterImportsFixer.php +++ b/src/Fixer/Import/SingleLineAfterImportsFixer.php @@ -142,7 +142,7 @@ protected function applyFix(\SplFileInfo $file, Tokens $tokens) } $nextMeaningfulAfterUseIndex = $tokens->getNextMeaningfulToken($insertIndex); if (null !== $nextMeaningfulAfterUseIndex && $tokens[$nextMeaningfulAfterUseIndex]->isGivenKind(T_USE)) { - if (substr_count($nextToken->getContent(), "\n") < 2) { + if (substr_count($nextToken->getContent(), "\n") < 1) { $tokens[$insertIndex] = new Token([T_WHITESPACE, $newline.$indent.ltrim($nextToken->getContent())]); } } else { diff --git a/tests/Fixer/Import/SingleLineAfterImportsFixerTest.php b/tests/Fixer/Import/SingleLineAfterImportsFixerTest.php index fe9ed3f7086..6bf9db34496 100644 --- a/tests/Fixer/Import/SingleLineAfterImportsFixerTest.php +++ b/tests/Fixer/Import/SingleLineAfterImportsFixerTest.php @@ -353,6 +353,14 @@ class Baz ', '