Skip to content

Commit f312223

Browse files
committed
Merge branch '2.13'
2 parents 4cacac4 + 555c35d commit f312223

File tree

3 files changed

+34
-2
lines changed

3 files changed

+34
-2
lines changed

src/Fixer/Basic/Psr4Fixer.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,13 +66,15 @@ protected function applyFix(\SplFileInfo $file, Tokens $tokens)
6666
} elseif ($token->isClassy()) {
6767
$prevToken = $tokens[$tokens->getPrevMeaningfulToken($index)];
6868
if ($prevToken->isGivenKind(T_NEW)) {
69+
break;
70+
}
71+
72+
if (null !== $classyName) {
6973
return;
7074
}
7175

7276
$classyIndex = $tokens->getNextMeaningfulToken($index);
7377
$classyName = $tokens[$classyIndex]->getContent();
74-
75-
break;
7678
}
7779
}
7880

tests/Fixer/Basic/Psr0FixerTest.php

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,21 @@ class Psr0_fOo_bAr {}
5757
$this->doTest($expected, $input, $file);
5858
}
5959

60+
public function testIgnoreMultipleClassyInFile()
61+
{
62+
$file = $this->getTestFile(__FILE__);
63+
64+
$expected = <<<'EOF'
65+
<?php
66+
namespace PhpCsFixer\Tests\Fixer\Basic;
67+
interface SomeInterfaceToBeUsedInTests {}
68+
class blah {}
69+
/* class foo */
70+
EOF;
71+
72+
$this->doTest($expected, null, $file);
73+
}
74+
6075
public function testFixClassName()
6176
{
6277
$file = $this->getTestFile(__FILE__);

tests/Fixer/Basic/Psr4FixerTest.php

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,21 @@ class Psr4_fOo_bAr {}
5757
$this->doTest($expected, $input, $file);
5858
}
5959

60+
public function testIgnoreMultipleClassyInFile()
61+
{
62+
$file = $this->getTestFile(__FILE__);
63+
64+
$expected = <<<'EOF'
65+
<?php
66+
namespace PhpCsFixer\Tests\Fixer\Basic;
67+
interface SomeInterfaceToBeUsedInTests {}
68+
class blah {}
69+
/* class foo */
70+
EOF;
71+
72+
$this->doTest($expected, null, $file);
73+
}
74+
6075
public function testFixClassName()
6176
{
6277
$file = $this->getTestFile(__FILE__);

0 commit comments

Comments
 (0)