Skip to content

Commit

Permalink
Merge pull request #873 from ergebnis/fix/custom-fixers
Browse files Browse the repository at this point in the history
Fix: Fetch custom fixers from `Config\RuleSet`
  • Loading branch information
localheinz authored Sep 16, 2023
2 parents bb8e4e4 + 66054d8 commit e2825e9
Show file tree
Hide file tree
Showing 15 changed files with 10 additions and 16 deletions.
2 changes: 1 addition & 1 deletion infection.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"text": ".build/infection/infection-log.txt"
},
"minCoveredMsi": 99,
"minMsi": 95,
"minMsi": 99,
"phpUnit": {
"configDir": "test\/Unit"
},
Expand Down
3 changes: 3 additions & 0 deletions psalm-baseline.xml
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,9 @@
<code>new FixerFactory()</code>
<code>registerBuiltInFixers</code>
</InternalMethod>
<InvalidArgument>
<code><![CDATA[self::createRuleSet()->customFixers()]]></code>
</InvalidArgument>
<PossiblyUnusedMethod>
<code>provideValidHeader</code>
</PossiblyUnusedMethod>
Expand Down
9 changes: 6 additions & 3 deletions test/Unit/RuleSet/AbstractRuleSetTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@

namespace Ergebnis\PhpCsFixer\Config\Test\Unit\RuleSet;

use Ergebnis\PhpCsFixer\Config\Factory;
use Ergebnis\PhpCsFixer\Config\Name;
use Ergebnis\PhpCsFixer\Config\PhpVersion;
use Ergebnis\PhpCsFixer\Config\RuleSet;
Expand Down Expand Up @@ -382,9 +381,13 @@ final protected static function fixersThatAreRegistered(): array

$fixerFactory->registerBuiltInFixers();

$fixersThatAreBuiltIn = $fixerFactory->getFixers();
$fixersThatShouldBeRegistered = \iterator_to_array(self::createRuleSet()->customFixers());

/** @var array<Fixer\FixerInterface> $fixers */
$fixers = \array_merge(
$fixerFactory->getFixers(),
Factory::fromRuleSet(self::createRuleSet())->getCustomFixers(),
$fixersThatAreBuiltIn,
$fixersThatShouldBeRegistered,
);

$fixersThatAreRegistered = \array_combine(
Expand Down
1 change: 0 additions & 1 deletion test/Unit/RuleSet/Php53Test.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@

#[Framework\Attributes\CoversClass(RuleSet\AbstractRuleSet::class)]
#[Framework\Attributes\CoversClass(RuleSet\Php53::class)]
#[Framework\Attributes\RequiresPhp('>=5.3')]
#[Framework\Attributes\UsesClass(Factory::class)]
#[Framework\Attributes\UsesClass(Name::class)]
#[Framework\Attributes\UsesClass(PhpVersion::class)]
Expand Down
1 change: 0 additions & 1 deletion test/Unit/RuleSet/Php54Test.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@

#[Framework\Attributes\CoversClass(RuleSet\AbstractRuleSet::class)]
#[Framework\Attributes\CoversClass(RuleSet\Php54::class)]
#[Framework\Attributes\RequiresPhp('>=5.4')]
#[Framework\Attributes\UsesClass(Factory::class)]
#[Framework\Attributes\UsesClass(Name::class)]
#[Framework\Attributes\UsesClass(PhpVersion::class)]
Expand Down
1 change: 0 additions & 1 deletion test/Unit/RuleSet/Php55Test.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@

#[Framework\Attributes\CoversClass(RuleSet\AbstractRuleSet::class)]
#[Framework\Attributes\CoversClass(RuleSet\Php55::class)]
#[Framework\Attributes\RequiresPhp('>=5.5')]
#[Framework\Attributes\UsesClass(Factory::class)]
#[Framework\Attributes\UsesClass(Name::class)]
#[Framework\Attributes\UsesClass(PhpVersion::class)]
Expand Down
1 change: 0 additions & 1 deletion test/Unit/RuleSet/Php56Test.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@

#[Framework\Attributes\CoversClass(RuleSet\AbstractRuleSet::class)]
#[Framework\Attributes\CoversClass(RuleSet\Php56::class)]
#[Framework\Attributes\RequiresPhp('>=5.6')]
#[Framework\Attributes\UsesClass(Factory::class)]
#[Framework\Attributes\UsesClass(Name::class)]
#[Framework\Attributes\UsesClass(PhpVersion::class)]
Expand Down
1 change: 0 additions & 1 deletion test/Unit/RuleSet/Php70Test.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@

#[Framework\Attributes\CoversClass(RuleSet\AbstractRuleSet::class)]
#[Framework\Attributes\CoversClass(RuleSet\Php70::class)]
#[Framework\Attributes\RequiresPhp('>=7.0')]
#[Framework\Attributes\UsesClass(Factory::class)]
#[Framework\Attributes\UsesClass(Name::class)]
#[Framework\Attributes\UsesClass(PhpVersion::class)]
Expand Down
1 change: 0 additions & 1 deletion test/Unit/RuleSet/Php71Test.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@

#[Framework\Attributes\CoversClass(RuleSet\AbstractRuleSet::class)]
#[Framework\Attributes\CoversClass(RuleSet\Php71::class)]
#[Framework\Attributes\RequiresPhp('>=7.1')]
#[Framework\Attributes\UsesClass(Factory::class)]
#[Framework\Attributes\UsesClass(Name::class)]
#[Framework\Attributes\UsesClass(PhpVersion::class)]
Expand Down
1 change: 0 additions & 1 deletion test/Unit/RuleSet/Php72Test.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@

#[Framework\Attributes\CoversClass(RuleSet\AbstractRuleSet::class)]
#[Framework\Attributes\CoversClass(RuleSet\Php72::class)]
#[Framework\Attributes\RequiresPhp('>=7.2')]
#[Framework\Attributes\UsesClass(Factory::class)]
#[Framework\Attributes\UsesClass(Name::class)]
#[Framework\Attributes\UsesClass(PhpVersion::class)]
Expand Down
1 change: 0 additions & 1 deletion test/Unit/RuleSet/Php73Test.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@

#[Framework\Attributes\CoversClass(RuleSet\AbstractRuleSet::class)]
#[Framework\Attributes\CoversClass(RuleSet\Php73::class)]
#[Framework\Attributes\RequiresPhp('>=7.3')]
#[Framework\Attributes\UsesClass(Factory::class)]
#[Framework\Attributes\UsesClass(Name::class)]
#[Framework\Attributes\UsesClass(PhpVersion::class)]
Expand Down
1 change: 0 additions & 1 deletion test/Unit/RuleSet/Php74Test.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@

#[Framework\Attributes\CoversClass(RuleSet\AbstractRuleSet::class)]
#[Framework\Attributes\CoversClass(RuleSet\Php74::class)]
#[Framework\Attributes\RequiresPhp('>=7.4')]
#[Framework\Attributes\UsesClass(Factory::class)]
#[Framework\Attributes\UsesClass(Name::class)]
#[Framework\Attributes\UsesClass(PhpVersion::class)]
Expand Down
1 change: 0 additions & 1 deletion test/Unit/RuleSet/Php80Test.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@

#[Framework\Attributes\CoversClass(RuleSet\AbstractRuleSet::class)]
#[Framework\Attributes\CoversClass(RuleSet\Php80::class)]
#[Framework\Attributes\RequiresPhp('>=8.0')]
#[Framework\Attributes\UsesClass(Factory::class)]
#[Framework\Attributes\UsesClass(Name::class)]
#[Framework\Attributes\UsesClass(PhpVersion::class)]
Expand Down
1 change: 0 additions & 1 deletion test/Unit/RuleSet/Php81Test.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@

#[Framework\Attributes\CoversClass(RuleSet\AbstractRuleSet::class)]
#[Framework\Attributes\CoversClass(RuleSet\Php81::class)]
#[Framework\Attributes\RequiresPhp('>=8.1')]
#[Framework\Attributes\UsesClass(Factory::class)]
#[Framework\Attributes\UsesClass(Name::class)]
#[Framework\Attributes\UsesClass(PhpVersion::class)]
Expand Down
1 change: 0 additions & 1 deletion test/Unit/RuleSet/Php82Test.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@

#[Framework\Attributes\CoversClass(RuleSet\AbstractRuleSet::class)]
#[Framework\Attributes\CoversClass(RuleSet\Php82::class)]
#[Framework\Attributes\RequiresPhp('>=8.2')]
#[Framework\Attributes\UsesClass(Factory::class)]
#[Framework\Attributes\UsesClass(Name::class)]
#[Framework\Attributes\UsesClass(PhpVersion::class)]
Expand Down

0 comments on commit e2825e9

Please sign in to comment.