Skip to content

Commit

Permalink
bug #5670 PhpUnitNamespacedFixer - do not try to fix constant (kubawe…
Browse files Browse the repository at this point in the history
…rlos)

This PR was merged into the 2.18 branch.

Discussion
----------

PhpUnitNamespacedFixer - do not try to fix constant

Commits
-------

6da4910 PhpUnitNamespacedFixer - do not try to fix constant
  • Loading branch information
keradus committed May 3, 2021
2 parents db7e1f1 + 6da4910 commit c8472bb
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/Fixer/PhpUnit/PhpUnitNamespacedFixer.php
Expand Up @@ -152,6 +152,11 @@ protected function applyFix(\SplFileInfo $file, Tokens $tokens)
break;
}

$prevIndex = $tokens->getPrevMeaningfulToken($currIndex);
if ($tokens[$prevIndex]->isGivenKind(T_CONST)) {
continue;
}

$originalClass = $tokens[$currIndex]->getContent();

if (1 !== Preg::match($this->originalClassRegEx, $originalClass)) {
Expand Down
7 changes: 7 additions & 0 deletions tests/Fixer/PhpUnit/PhpUnitNamespacedFixerTest.php
Expand Up @@ -235,6 +235,13 @@ public function aaa()
echo \PHPUnit_Runner_Version::id();
',
],
[
'<?php
final class MyTest extends TestCase
{
const PHPUNIT_FOO = "foo";
}',
],
];
}

Expand Down

0 comments on commit c8472bb

Please sign in to comment.