Skip to content

Commit

Permalink
Merge branch '2.15' into 2.16
Browse files Browse the repository at this point in the history
  • Loading branch information
keradus committed Jun 27, 2020
2 parents 140d38a + dfc4f07 commit 5e6acea
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/Fixer/Import/SingleLineAfterImportsFixer.php
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
7 changes: 7 additions & 0 deletions tests/Fixer/Import/SingleLineAfterImportsFixerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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", '<?php
use Foo;
class Bar {}
'),
],
];
}

Expand Down

0 comments on commit 5e6acea

Please sign in to comment.