diff --git a/CHANGELOG.md b/CHANGELOG.md index e48d7180..b1470039 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,7 @@ For a full diff see [`5.16.0...main`][5.16.0...main]. - Extracted `Config\Name` as a value object ([#870]), by [@localheinz] - Extracted `Config\PhpVersion` as a value object ([#871]), by [@localheinz] - Extracted `Config\Rules` as a value object ([#874]), by [@localheinz] +- Extracted `Config\Fixers` as a value object ([#883]), by [@localheinz] ### Changed @@ -1194,6 +1195,7 @@ For a full diff see [`d899e77...1.0.0`][d899e77...1.0.0]. [#880]: https://github.com/ergebnis/php-cs-fixer-config/pull/880 [#881]: https://github.com/ergebnis/php-cs-fixer-config/pull/881 [#882]: https://github.com/ergebnis/php-cs-fixer-config/pull/882 +[#883]: https://github.com/ergebnis/php-cs-fixer-config/pull/883 [@dependabot]: https://github.com/apps/dependabot [@linuxjuggler]: https://github.com/linuxjuggler diff --git a/psalm-baseline.xml b/psalm-baseline.xml index ac4a0705..066139fd 100644 --- a/psalm-baseline.xml +++ b/psalm-baseline.xml @@ -1,5 +1,10 @@ + + + $value + + |bool>]]> - - - customFixers]]> - iterable - - Command\FixCommandExitStatusCalculator::EXIT_STATUS_FLAG_HAS_INVALID_CONFIG @@ -28,6 +27,11 @@ provideTargetPhpVersionLessThanOrEqualToCurrentPhpVersion + + + $value + + provideValidValue @@ -49,9 +53,6 @@ new FixerFactory() registerBuiltInFixers - - customFixers()]]> - provideValidHeader diff --git a/src/Factory.php b/src/Factory.php index b7a3d5dc..2fb80c64 100644 --- a/src/Factory.php +++ b/src/Factory.php @@ -38,7 +38,7 @@ public static function fromRuleSet( $config = new Config($ruleSet->name()->toString()); - $config->registerCustomFixers($ruleSet->customFixers()); + $config->registerCustomFixers($ruleSet->customFixers()->toArray()); $config->setRiskyAllowed(true); $config->setRules($ruleSet->rules()->toArray()); diff --git a/src/Fixers.php b/src/Fixers.php new file mode 100644 index 00000000..328b9970 --- /dev/null +++ b/src/Fixers.php @@ -0,0 +1,71 @@ + + */ + private readonly array $value; + + private function __construct(Fixer\FixerInterface ...$value) + { + $this->value = $value; + } + + public static function empty(): self + { + return new self(); + } + + public static function fromFixers(Fixer\FixerInterface ...$value): self + { + return new self(...$value); + } + + /** + * @param iterable $iterable + * + * @throws \InvalidArgumentException + */ + public static function fromIterable(iterable $iterable): self + { + $value = []; + + foreach ($iterable as $iterated) { + if (!$iterated instanceof Fixer\FixerInterface) { + throw new \InvalidArgumentException(\sprintf( + 'Expected iterable to contain only instances of %s, got %s instead.', + Fixer\FixerInterface::class, + \get_debug_type($iterated), + )); + } + + $value[] = $iterated; + } + + return new self(...$value); + } + + /** + * @return list + */ + public function toArray(): array + { + return $this->value; + } +} diff --git a/src/RuleSet.php b/src/RuleSet.php index e218a77a..f47cfcc0 100644 --- a/src/RuleSet.php +++ b/src/RuleSet.php @@ -13,16 +13,12 @@ namespace Ergebnis\PhpCsFixer\Config; -use PhpCsFixer\Fixer; - interface RuleSet { /** * Returns custom fixers required by this rule set. - * - * @return iterable */ - public function customFixers(): iterable; + public function customFixers(): Fixers; /** * Returns the name of the rule set. diff --git a/src/RuleSet/Php53.php b/src/RuleSet/Php53.php index 3190e8cb..9ea79966 100644 --- a/src/RuleSet/Php53.php +++ b/src/RuleSet/Php53.php @@ -14,6 +14,7 @@ namespace Ergebnis\PhpCsFixer\Config\RuleSet; use Ergebnis\PhpCsFixer\Config\ExplicitRuleSet; +use Ergebnis\PhpCsFixer\Config\Fixers; use Ergebnis\PhpCsFixer\Config\Name; use Ergebnis\PhpCsFixer\Config\PhpVersion; use Ergebnis\PhpCsFixer\Config\Rules; @@ -845,9 +846,9 @@ public function __construct(?string $header = null) ]; } - public function customFixers(): iterable + public function customFixers(): Fixers { - yield from []; + return Fixers::empty(); } public function name(): Name diff --git a/src/RuleSet/Php54.php b/src/RuleSet/Php54.php index ecd54f0b..f9b09370 100644 --- a/src/RuleSet/Php54.php +++ b/src/RuleSet/Php54.php @@ -14,6 +14,7 @@ namespace Ergebnis\PhpCsFixer\Config\RuleSet; use Ergebnis\PhpCsFixer\Config\ExplicitRuleSet; +use Ergebnis\PhpCsFixer\Config\Fixers; use Ergebnis\PhpCsFixer\Config\Name; use Ergebnis\PhpCsFixer\Config\PhpVersion; use Ergebnis\PhpCsFixer\Config\Rules; @@ -847,9 +848,9 @@ public function __construct(?string $header = null) ]; } - public function customFixers(): iterable + public function customFixers(): Fixers { - yield from []; + return Fixers::empty(); } public function name(): Name diff --git a/src/RuleSet/Php55.php b/src/RuleSet/Php55.php index 8692319c..a9493f7a 100644 --- a/src/RuleSet/Php55.php +++ b/src/RuleSet/Php55.php @@ -14,6 +14,7 @@ namespace Ergebnis\PhpCsFixer\Config\RuleSet; use Ergebnis\PhpCsFixer\Config\ExplicitRuleSet; +use Ergebnis\PhpCsFixer\Config\Fixers; use Ergebnis\PhpCsFixer\Config\Name; use Ergebnis\PhpCsFixer\Config\PhpVersion; use Ergebnis\PhpCsFixer\Config\Rules; @@ -856,9 +857,9 @@ public function __construct(?string $header = null) ]; } - public function customFixers(): iterable + public function customFixers(): Fixers { - yield from []; + return Fixers::empty(); } public function name(): Name diff --git a/src/RuleSet/Php56.php b/src/RuleSet/Php56.php index 551f52dc..ec98d3c4 100644 --- a/src/RuleSet/Php56.php +++ b/src/RuleSet/Php56.php @@ -14,6 +14,7 @@ namespace Ergebnis\PhpCsFixer\Config\RuleSet; use Ergebnis\PhpCsFixer\Config\ExplicitRuleSet; +use Ergebnis\PhpCsFixer\Config\Fixers; use Ergebnis\PhpCsFixer\Config\Name; use Ergebnis\PhpCsFixer\Config\PhpVersion; use Ergebnis\PhpCsFixer\Config\Rules; @@ -856,9 +857,9 @@ public function __construct(?string $header = null) ]; } - public function customFixers(): iterable + public function customFixers(): Fixers { - yield from []; + return Fixers::empty(); } public function name(): Name diff --git a/src/RuleSet/Php70.php b/src/RuleSet/Php70.php index 2ade9949..e8d8bcfa 100644 --- a/src/RuleSet/Php70.php +++ b/src/RuleSet/Php70.php @@ -14,6 +14,7 @@ namespace Ergebnis\PhpCsFixer\Config\RuleSet; use Ergebnis\PhpCsFixer\Config\ExplicitRuleSet; +use Ergebnis\PhpCsFixer\Config\Fixers; use Ergebnis\PhpCsFixer\Config\Name; use Ergebnis\PhpCsFixer\Config\PhpVersion; use Ergebnis\PhpCsFixer\Config\Rules; @@ -857,9 +858,9 @@ public function __construct(?string $header = null) ]; } - public function customFixers(): iterable + public function customFixers(): Fixers { - yield from []; + return Fixers::empty(); } public function name(): Name diff --git a/src/RuleSet/Php71.php b/src/RuleSet/Php71.php index bab18ace..28e82d88 100644 --- a/src/RuleSet/Php71.php +++ b/src/RuleSet/Php71.php @@ -14,6 +14,7 @@ namespace Ergebnis\PhpCsFixer\Config\RuleSet; use Ergebnis\PhpCsFixer\Config\ExplicitRuleSet; +use Ergebnis\PhpCsFixer\Config\Fixers; use Ergebnis\PhpCsFixer\Config\Name; use Ergebnis\PhpCsFixer\Config\PhpVersion; use Ergebnis\PhpCsFixer\Config\Rules; @@ -859,9 +860,9 @@ public function __construct(?string $header = null) ]; } - public function customFixers(): iterable + public function customFixers(): Fixers { - yield from []; + return Fixers::empty(); } public function name(): Name diff --git a/src/RuleSet/Php72.php b/src/RuleSet/Php72.php index b1eaf6a5..9cb496df 100644 --- a/src/RuleSet/Php72.php +++ b/src/RuleSet/Php72.php @@ -14,6 +14,7 @@ namespace Ergebnis\PhpCsFixer\Config\RuleSet; use Ergebnis\PhpCsFixer\Config\ExplicitRuleSet; +use Ergebnis\PhpCsFixer\Config\Fixers; use Ergebnis\PhpCsFixer\Config\Name; use Ergebnis\PhpCsFixer\Config\PhpVersion; use Ergebnis\PhpCsFixer\Config\Rules; @@ -859,9 +860,9 @@ public function __construct(?string $header = null) ]; } - public function customFixers(): iterable + public function customFixers(): Fixers { - yield from []; + return Fixers::empty(); } public function name(): Name diff --git a/src/RuleSet/Php73.php b/src/RuleSet/Php73.php index 3303a8db..7d266173 100644 --- a/src/RuleSet/Php73.php +++ b/src/RuleSet/Php73.php @@ -14,6 +14,7 @@ namespace Ergebnis\PhpCsFixer\Config\RuleSet; use Ergebnis\PhpCsFixer\Config\ExplicitRuleSet; +use Ergebnis\PhpCsFixer\Config\Fixers; use Ergebnis\PhpCsFixer\Config\Name; use Ergebnis\PhpCsFixer\Config\PhpVersion; use Ergebnis\PhpCsFixer\Config\Rules; @@ -860,9 +861,9 @@ public function __construct(?string $header = null) ]; } - public function customFixers(): iterable + public function customFixers(): Fixers { - yield from []; + return Fixers::empty(); } public function name(): Name diff --git a/src/RuleSet/Php74.php b/src/RuleSet/Php74.php index 8c5530ef..f4bd8624 100644 --- a/src/RuleSet/Php74.php +++ b/src/RuleSet/Php74.php @@ -14,6 +14,7 @@ namespace Ergebnis\PhpCsFixer\Config\RuleSet; use Ergebnis\PhpCsFixer\Config\ExplicitRuleSet; +use Ergebnis\PhpCsFixer\Config\Fixers; use Ergebnis\PhpCsFixer\Config\Name; use Ergebnis\PhpCsFixer\Config\PhpVersion; use Ergebnis\PhpCsFixer\Config\Rules; @@ -863,9 +864,9 @@ public function __construct(?string $header = null) ]; } - public function customFixers(): iterable + public function customFixers(): Fixers { - yield from []; + return Fixers::empty(); } public function name(): Name diff --git a/src/RuleSet/Php80.php b/src/RuleSet/Php80.php index f0acdafb..a3401800 100644 --- a/src/RuleSet/Php80.php +++ b/src/RuleSet/Php80.php @@ -14,6 +14,7 @@ namespace Ergebnis\PhpCsFixer\Config\RuleSet; use Ergebnis\PhpCsFixer\Config\ExplicitRuleSet; +use Ergebnis\PhpCsFixer\Config\Fixers; use Ergebnis\PhpCsFixer\Config\Name; use Ergebnis\PhpCsFixer\Config\PhpVersion; use Ergebnis\PhpCsFixer\Config\Rules; @@ -872,9 +873,9 @@ public function __construct(?string $header = null) ]; } - public function customFixers(): iterable + public function customFixers(): Fixers { - yield from []; + return Fixers::empty(); } public function name(): Name diff --git a/src/RuleSet/Php81.php b/src/RuleSet/Php81.php index 020a05e4..0e01b0ce 100644 --- a/src/RuleSet/Php81.php +++ b/src/RuleSet/Php81.php @@ -14,6 +14,7 @@ namespace Ergebnis\PhpCsFixer\Config\RuleSet; use Ergebnis\PhpCsFixer\Config\ExplicitRuleSet; +use Ergebnis\PhpCsFixer\Config\Fixers; use Ergebnis\PhpCsFixer\Config\Name; use Ergebnis\PhpCsFixer\Config\PhpVersion; use Ergebnis\PhpCsFixer\Config\Rules; @@ -874,9 +875,9 @@ public function __construct(?string $header = null) ]; } - public function customFixers(): iterable + public function customFixers(): Fixers { - yield from []; + return Fixers::empty(); } public function name(): Name diff --git a/src/RuleSet/Php82.php b/src/RuleSet/Php82.php index 48db29ed..75c2600a 100644 --- a/src/RuleSet/Php82.php +++ b/src/RuleSet/Php82.php @@ -14,6 +14,7 @@ namespace Ergebnis\PhpCsFixer\Config\RuleSet; use Ergebnis\PhpCsFixer\Config\ExplicitRuleSet; +use Ergebnis\PhpCsFixer\Config\Fixers; use Ergebnis\PhpCsFixer\Config\Name; use Ergebnis\PhpCsFixer\Config\PhpVersion; use Ergebnis\PhpCsFixer\Config\Rules; @@ -874,9 +875,9 @@ public function __construct(?string $header = null) ]; } - public function customFixers(): iterable + public function customFixers(): Fixers { - yield from []; + return Fixers::empty(); } public function name(): Name diff --git a/test/Double/Config/RuleSet/DummyRuleSet.php b/test/Double/Config/RuleSet/DummyRuleSet.php index 4424c75f..570ee937 100644 --- a/test/Double/Config/RuleSet/DummyRuleSet.php +++ b/test/Double/Config/RuleSet/DummyRuleSet.php @@ -13,6 +13,7 @@ namespace Ergebnis\PhpCsFixer\Config\Test\Double\Config\RuleSet; +use Ergebnis\PhpCsFixer\Config\Fixers; use Ergebnis\PhpCsFixer\Config\Name; use Ergebnis\PhpCsFixer\Config\PhpVersion; use Ergebnis\PhpCsFixer\Config\Rules; @@ -21,14 +22,14 @@ final class DummyRuleSet implements RuleSet { public function __construct( - private readonly iterable $customFixers, + private readonly Fixers $customFixers, private readonly Name $name, private readonly PhpVersion $phpVersion, private readonly Rules $rules, ) { } - public function customFixers(): iterable + public function customFixers(): Fixers { return $this->customFixers; } diff --git a/test/Unit/FactoryTest.php b/test/Unit/FactoryTest.php index 6d9a3b3f..7fc81639 100644 --- a/test/Unit/FactoryTest.php +++ b/test/Unit/FactoryTest.php @@ -14,6 +14,7 @@ namespace Ergebnis\PhpCsFixer\Config\Test\Unit; use Ergebnis\PhpCsFixer\Config\Factory; +use Ergebnis\PhpCsFixer\Config\Fixers; use Ergebnis\PhpCsFixer\Config\Name; use Ergebnis\PhpCsFixer\Config\PhpVersion; use Ergebnis\PhpCsFixer\Config\Rules; @@ -22,6 +23,7 @@ use PHPUnit\Framework; #[Framework\Attributes\CoversClass(Factory::class)] +#[Framework\Attributes\UsesClass(Fixers::class)] #[Framework\Attributes\UsesClass(Name::class)] #[Framework\Attributes\UsesClass(PhpVersion::class)] #[Framework\Attributes\UsesClass(PhpVersion\Major::class)] @@ -41,7 +43,7 @@ public function testFromRuleSetThrowsRuntimeExceptionWhenCurrentPhpVersionIsLess ); $ruleSet = new Test\Double\Config\RuleSet\DummyRuleSet( - [], + Fixers::empty(), Name::fromString(self::faker()->word()), $phpVersion, Rules::fromArray([]), @@ -60,11 +62,11 @@ public function testFromRuleSetThrowsRuntimeExceptionWhenCurrentPhpVersionIsLess #[Framework\Attributes\DataProvider('provideTargetPhpVersionLessThanOrEqualToCurrentPhpVersion')] public function testFromRuleSetCreatesConfigWhenCurrentPhpVersionIsEqualToOrGreaterThanTargetPhpVersion(PhpVersion $targetPhpVersion): void { - $customFixers = [ + $customFixers = Fixers::fromFixers( $this->createStub(Fixer\FixerInterface::class), $this->createStub(Fixer\FixerInterface::class), $this->createStub(Fixer\FixerInterface::class), - ]; + ); $rules = Rules::fromArray([ 'foo' => true, @@ -82,7 +84,7 @@ public function testFromRuleSetCreatesConfigWhenCurrentPhpVersionIsEqualToOrGrea $config = Factory::fromRuleSet($ruleSet); - self::assertEquals($customFixers, $config->getCustomFixers()); + self::assertEquals($customFixers->toArray(), $config->getCustomFixers()); self::assertTrue($config->getRiskyAllowed()); self::assertSame($rules->toArray(), $config->getRules()); self::assertTrue($config->getUsingCache()); @@ -107,11 +109,11 @@ public static function provideTargetPhpVersionLessThanOrEqualToCurrentPhpVersion public function testFromRuleSetCreatesConfigWithOverrideRules(): void { - $customFixers = [ + $customFixers = Fixers::fromFixers( $this->createStub(Fixer\FixerInterface::class), $this->createStub(Fixer\FixerInterface::class), $this->createStub(Fixer\FixerInterface::class), - ]; + ); $rules = Rules::fromArray([ 'foo' => true, @@ -140,7 +142,7 @@ public function testFromRuleSetCreatesConfigWithOverrideRules(): void $overrideRules, ); - self::assertEquals($customFixers, $config->getCustomFixers()); + self::assertEquals($customFixers->toArray(), $config->getCustomFixers()); self::assertTrue($config->getRiskyAllowed()); self::assertEquals($rules->merge($overrideRules)->toArray(), $config->getRules()); self::assertTrue($config->getUsingCache()); diff --git a/test/Unit/FixersTest.php b/test/Unit/FixersTest.php new file mode 100644 index 00000000..c5f91088 --- /dev/null +++ b/test/Unit/FixersTest.php @@ -0,0 +1,88 @@ +toArray()); + } + + public function testFromFixersReturnsFixers(): void + { + $value = [ + $this->createStub(Fixer\FixerInterface::class), + $this->createStub(Fixer\FixerInterface::class), + $this->createStub(Fixer\FixerInterface::class), + ]; + + $fixers = Fixers::fromFixers(...$value); + + self::assertSame($value, $fixers->toArray()); + } + + public function testFromIterableRejectsInvalidValue(): void + { + $value = [ + $this->createStub(Fixer\FixerInterface::class), + new \stdClass(), + $this->createStub(Fixer\FixerInterface::class), + ]; + + $this->expectException(\InvalidArgumentException::class); + $this->expectExceptionMessage( + \sprintf( + 'Expected iterable to contain only instances of %s, got %s instead.', + Fixer\FixerInterface::class, + stdClass::class, + ), + ); + + Fixers::fromIterable($value); + } + + public function testFromIterableReturnsFixersWhenValueIsArray(): void + { + $value = [ + $this->createStub(Fixer\FixerInterface::class), + $this->createStub(Fixer\FixerInterface::class), + $this->createStub(Fixer\FixerInterface::class), + ]; + + $fixers = Fixers::fromIterable($value); + + self::assertSame($value, $fixers->toArray()); + } + + public function testFromIterableReturnsFixersWhenValueIsTraversable(): void + { + $value = [ + $this->createStub(Fixer\FixerInterface::class), + $this->createStub(Fixer\FixerInterface::class), + $this->createStub(Fixer\FixerInterface::class), + ]; + + $iterable = new ArrayIterator($value); + + $fixers = Fixers::fromIterable($iterable); + + self::assertSame($value, $fixers->toArray()); + } +} diff --git a/test/Unit/RuleSet/AbstractRuleSetTestCase.php b/test/Unit/RuleSet/AbstractRuleSetTestCase.php index 179c398f..8c22960b 100644 --- a/test/Unit/RuleSet/AbstractRuleSetTestCase.php +++ b/test/Unit/RuleSet/AbstractRuleSetTestCase.php @@ -13,6 +13,7 @@ namespace Ergebnis\PhpCsFixer\Config\Test\Unit\RuleSet; +use Ergebnis\PhpCsFixer\Config\Fixers; use Ergebnis\PhpCsFixer\Config\Name; use Ergebnis\PhpCsFixer\Config\PhpVersion; use Ergebnis\PhpCsFixer\Config\Rules; @@ -216,7 +217,7 @@ final public static function provideValidHeader(): \Generator } } - abstract protected function expectedCustomFixers(): iterable; + abstract protected function expectedCustomFixers(): Fixers; abstract protected function expectedName(): Name; @@ -239,7 +240,7 @@ final protected static function fixersThatAreRegistered(): array $fixerFactory->registerBuiltInFixers(); $fixersThatAreBuiltIn = $fixerFactory->getFixers(); - $fixersThatShouldBeRegistered = \iterator_to_array(static::createRuleSet()->customFixers()); + $fixersThatShouldBeRegistered = static::createRuleSet()->customFixers()->toArray(); /** @var array $fixers */ $fixers = \array_merge( diff --git a/test/Unit/RuleSet/Php53Test.php b/test/Unit/RuleSet/Php53Test.php index 1f30fb91..9f72b364 100644 --- a/test/Unit/RuleSet/Php53Test.php +++ b/test/Unit/RuleSet/Php53Test.php @@ -14,6 +14,7 @@ namespace Ergebnis\PhpCsFixer\Config\Test\Unit\RuleSet; use Ergebnis\PhpCsFixer\Config\Factory; +use Ergebnis\PhpCsFixer\Config\Fixers; use Ergebnis\PhpCsFixer\Config\Name; use Ergebnis\PhpCsFixer\Config\PhpVersion; use Ergebnis\PhpCsFixer\Config\Rules; @@ -22,6 +23,7 @@ #[Framework\Attributes\CoversClass(RuleSet\Php53::class)] #[Framework\Attributes\UsesClass(Factory::class)] +#[Framework\Attributes\UsesClass(Fixers::class)] #[Framework\Attributes\UsesClass(Name::class)] #[Framework\Attributes\UsesClass(PhpVersion::class)] #[Framework\Attributes\UsesClass(PhpVersion\Major::class)] @@ -35,9 +37,9 @@ protected static function createRuleSet(?string $header = null): RuleSet return new RuleSet\Php53($header); } - protected function expectedCustomFixers(): iterable + protected function expectedCustomFixers(): Fixers { - yield from []; + return Fixers::empty(); } protected function expectedName(): Name diff --git a/test/Unit/RuleSet/Php54Test.php b/test/Unit/RuleSet/Php54Test.php index d2641a10..cc5d7566 100644 --- a/test/Unit/RuleSet/Php54Test.php +++ b/test/Unit/RuleSet/Php54Test.php @@ -14,6 +14,7 @@ namespace Ergebnis\PhpCsFixer\Config\Test\Unit\RuleSet; use Ergebnis\PhpCsFixer\Config\Factory; +use Ergebnis\PhpCsFixer\Config\Fixers; use Ergebnis\PhpCsFixer\Config\Name; use Ergebnis\PhpCsFixer\Config\PhpVersion; use Ergebnis\PhpCsFixer\Config\Rules; @@ -22,6 +23,7 @@ #[Framework\Attributes\CoversClass(RuleSet\Php54::class)] #[Framework\Attributes\UsesClass(Factory::class)] +#[Framework\Attributes\UsesClass(Fixers::class)] #[Framework\Attributes\UsesClass(Name::class)] #[Framework\Attributes\UsesClass(PhpVersion::class)] #[Framework\Attributes\UsesClass(PhpVersion\Major::class)] @@ -35,9 +37,9 @@ protected static function createRuleSet(?string $header = null): RuleSet return new RuleSet\Php54($header); } - protected function expectedCustomFixers(): iterable + protected function expectedCustomFixers(): Fixers { - yield from []; + return Fixers::empty(); } protected function expectedName(): Name diff --git a/test/Unit/RuleSet/Php55Test.php b/test/Unit/RuleSet/Php55Test.php index 94017b11..215b77c9 100644 --- a/test/Unit/RuleSet/Php55Test.php +++ b/test/Unit/RuleSet/Php55Test.php @@ -14,6 +14,7 @@ namespace Ergebnis\PhpCsFixer\Config\Test\Unit\RuleSet; use Ergebnis\PhpCsFixer\Config\Factory; +use Ergebnis\PhpCsFixer\Config\Fixers; use Ergebnis\PhpCsFixer\Config\Name; use Ergebnis\PhpCsFixer\Config\PhpVersion; use Ergebnis\PhpCsFixer\Config\Rules; @@ -22,6 +23,7 @@ #[Framework\Attributes\CoversClass(RuleSet\Php55::class)] #[Framework\Attributes\UsesClass(Factory::class)] +#[Framework\Attributes\UsesClass(Fixers::class)] #[Framework\Attributes\UsesClass(Name::class)] #[Framework\Attributes\UsesClass(PhpVersion::class)] #[Framework\Attributes\UsesClass(PhpVersion\Major::class)] @@ -30,9 +32,9 @@ #[Framework\Attributes\UsesClass(Rules::class)] final class Php55Test extends ExplicitRuleSetTestCase { - public function expectedCustomFixers(): iterable + protected function expectedCustomFixers(): Fixers { - yield from []; + return Fixers::empty(); } protected static function createRuleSet(?string $header = null): RuleSet diff --git a/test/Unit/RuleSet/Php56Test.php b/test/Unit/RuleSet/Php56Test.php index d3039553..6e02c0e3 100644 --- a/test/Unit/RuleSet/Php56Test.php +++ b/test/Unit/RuleSet/Php56Test.php @@ -14,6 +14,7 @@ namespace Ergebnis\PhpCsFixer\Config\Test\Unit\RuleSet; use Ergebnis\PhpCsFixer\Config\Factory; +use Ergebnis\PhpCsFixer\Config\Fixers; use Ergebnis\PhpCsFixer\Config\Name; use Ergebnis\PhpCsFixer\Config\PhpVersion; use Ergebnis\PhpCsFixer\Config\Rules; @@ -22,6 +23,7 @@ #[Framework\Attributes\CoversClass(RuleSet\Php56::class)] #[Framework\Attributes\UsesClass(Factory::class)] +#[Framework\Attributes\UsesClass(Fixers::class)] #[Framework\Attributes\UsesClass(Name::class)] #[Framework\Attributes\UsesClass(PhpVersion::class)] #[Framework\Attributes\UsesClass(PhpVersion\Major::class)] @@ -35,9 +37,9 @@ protected static function createRuleSet(?string $header = null): RuleSet return new RuleSet\Php56($header); } - protected function expectedCustomFixers(): iterable + protected function expectedCustomFixers(): Fixers { - yield from []; + return Fixers::empty(); } protected function expectedName(): Name diff --git a/test/Unit/RuleSet/Php70Test.php b/test/Unit/RuleSet/Php70Test.php index dbc1bd31..a1b553bb 100644 --- a/test/Unit/RuleSet/Php70Test.php +++ b/test/Unit/RuleSet/Php70Test.php @@ -14,6 +14,7 @@ namespace Ergebnis\PhpCsFixer\Config\Test\Unit\RuleSet; use Ergebnis\PhpCsFixer\Config\Factory; +use Ergebnis\PhpCsFixer\Config\Fixers; use Ergebnis\PhpCsFixer\Config\Name; use Ergebnis\PhpCsFixer\Config\PhpVersion; use Ergebnis\PhpCsFixer\Config\Rules; @@ -22,6 +23,7 @@ #[Framework\Attributes\CoversClass(RuleSet\Php70::class)] #[Framework\Attributes\UsesClass(Factory::class)] +#[Framework\Attributes\UsesClass(Fixers::class)] #[Framework\Attributes\UsesClass(Name::class)] #[Framework\Attributes\UsesClass(PhpVersion::class)] #[Framework\Attributes\UsesClass(PhpVersion\Major::class)] @@ -35,9 +37,9 @@ protected static function createRuleSet(?string $header = null): RuleSet return new RuleSet\Php70($header); } - protected function expectedCustomFixers(): iterable + protected function expectedCustomFixers(): Fixers { - yield from []; + return Fixers::empty(); } protected function expectedName(): Name diff --git a/test/Unit/RuleSet/Php71Test.php b/test/Unit/RuleSet/Php71Test.php index 8143eb56..1d790421 100644 --- a/test/Unit/RuleSet/Php71Test.php +++ b/test/Unit/RuleSet/Php71Test.php @@ -14,6 +14,7 @@ namespace Ergebnis\PhpCsFixer\Config\Test\Unit\RuleSet; use Ergebnis\PhpCsFixer\Config\Factory; +use Ergebnis\PhpCsFixer\Config\Fixers; use Ergebnis\PhpCsFixer\Config\Name; use Ergebnis\PhpCsFixer\Config\PhpVersion; use Ergebnis\PhpCsFixer\Config\Rules; @@ -22,6 +23,7 @@ #[Framework\Attributes\CoversClass(RuleSet\Php71::class)] #[Framework\Attributes\UsesClass(Factory::class)] +#[Framework\Attributes\UsesClass(Fixers::class)] #[Framework\Attributes\UsesClass(Name::class)] #[Framework\Attributes\UsesClass(PhpVersion::class)] #[Framework\Attributes\UsesClass(PhpVersion\Major::class)] @@ -35,9 +37,9 @@ protected static function createRuleSet(?string $header = null): RuleSet return new RuleSet\Php71($header); } - protected function expectedCustomFixers(): iterable + protected function expectedCustomFixers(): Fixers { - yield from []; + return Fixers::empty(); } protected function expectedName(): Name diff --git a/test/Unit/RuleSet/Php72Test.php b/test/Unit/RuleSet/Php72Test.php index a8f661a0..5c97b4ff 100644 --- a/test/Unit/RuleSet/Php72Test.php +++ b/test/Unit/RuleSet/Php72Test.php @@ -14,6 +14,7 @@ namespace Ergebnis\PhpCsFixer\Config\Test\Unit\RuleSet; use Ergebnis\PhpCsFixer\Config\Factory; +use Ergebnis\PhpCsFixer\Config\Fixers; use Ergebnis\PhpCsFixer\Config\Name; use Ergebnis\PhpCsFixer\Config\PhpVersion; use Ergebnis\PhpCsFixer\Config\Rules; @@ -22,6 +23,7 @@ #[Framework\Attributes\CoversClass(RuleSet\Php72::class)] #[Framework\Attributes\UsesClass(Factory::class)] +#[Framework\Attributes\UsesClass(Fixers::class)] #[Framework\Attributes\UsesClass(Name::class)] #[Framework\Attributes\UsesClass(PhpVersion::class)] #[Framework\Attributes\UsesClass(PhpVersion\Major::class)] @@ -35,9 +37,9 @@ protected static function createRuleSet(?string $header = null): RuleSet return new RuleSet\Php72($header); } - protected function expectedCustomFixers(): iterable + protected function expectedCustomFixers(): Fixers { - yield from []; + return Fixers::empty(); } protected function expectedName(): Name diff --git a/test/Unit/RuleSet/Php73Test.php b/test/Unit/RuleSet/Php73Test.php index 656ef2cf..fd9e5ffc 100644 --- a/test/Unit/RuleSet/Php73Test.php +++ b/test/Unit/RuleSet/Php73Test.php @@ -14,6 +14,7 @@ namespace Ergebnis\PhpCsFixer\Config\Test\Unit\RuleSet; use Ergebnis\PhpCsFixer\Config\Factory; +use Ergebnis\PhpCsFixer\Config\Fixers; use Ergebnis\PhpCsFixer\Config\Name; use Ergebnis\PhpCsFixer\Config\PhpVersion; use Ergebnis\PhpCsFixer\Config\Rules; @@ -22,6 +23,7 @@ #[Framework\Attributes\CoversClass(RuleSet\Php73::class)] #[Framework\Attributes\UsesClass(Factory::class)] +#[Framework\Attributes\UsesClass(Fixers::class)] #[Framework\Attributes\UsesClass(Name::class)] #[Framework\Attributes\UsesClass(PhpVersion::class)] #[Framework\Attributes\UsesClass(PhpVersion\Major::class)] @@ -35,9 +37,9 @@ protected static function createRuleSet(?string $header = null): RuleSet return new RuleSet\Php73($header); } - protected function expectedCustomFixers(): iterable + protected function expectedCustomFixers(): Fixers { - yield from []; + return Fixers::empty(); } protected function expectedName(): Name diff --git a/test/Unit/RuleSet/Php74Test.php b/test/Unit/RuleSet/Php74Test.php index 47ed1b60..eae645ee 100644 --- a/test/Unit/RuleSet/Php74Test.php +++ b/test/Unit/RuleSet/Php74Test.php @@ -14,6 +14,7 @@ namespace Ergebnis\PhpCsFixer\Config\Test\Unit\RuleSet; use Ergebnis\PhpCsFixer\Config\Factory; +use Ergebnis\PhpCsFixer\Config\Fixers; use Ergebnis\PhpCsFixer\Config\Name; use Ergebnis\PhpCsFixer\Config\PhpVersion; use Ergebnis\PhpCsFixer\Config\Rules; @@ -22,6 +23,7 @@ #[Framework\Attributes\CoversClass(RuleSet\Php74::class)] #[Framework\Attributes\UsesClass(Factory::class)] +#[Framework\Attributes\UsesClass(Fixers::class)] #[Framework\Attributes\UsesClass(Name::class)] #[Framework\Attributes\UsesClass(PhpVersion::class)] #[Framework\Attributes\UsesClass(PhpVersion\Major::class)] @@ -35,9 +37,9 @@ protected static function createRuleSet(?string $header = null): RuleSet return new RuleSet\Php74($header); } - protected function expectedCustomFixers(): iterable + protected function expectedCustomFixers(): Fixers { - yield from []; + return Fixers::empty(); } protected function expectedName(): Name diff --git a/test/Unit/RuleSet/Php80Test.php b/test/Unit/RuleSet/Php80Test.php index f8f2e987..5efea246 100644 --- a/test/Unit/RuleSet/Php80Test.php +++ b/test/Unit/RuleSet/Php80Test.php @@ -14,6 +14,7 @@ namespace Ergebnis\PhpCsFixer\Config\Test\Unit\RuleSet; use Ergebnis\PhpCsFixer\Config\Factory; +use Ergebnis\PhpCsFixer\Config\Fixers; use Ergebnis\PhpCsFixer\Config\Name; use Ergebnis\PhpCsFixer\Config\PhpVersion; use Ergebnis\PhpCsFixer\Config\Rules; @@ -22,6 +23,7 @@ #[Framework\Attributes\CoversClass(RuleSet\Php80::class)] #[Framework\Attributes\UsesClass(Factory::class)] +#[Framework\Attributes\UsesClass(Fixers::class)] #[Framework\Attributes\UsesClass(Name::class)] #[Framework\Attributes\UsesClass(PhpVersion::class)] #[Framework\Attributes\UsesClass(PhpVersion\Major::class)] @@ -35,9 +37,9 @@ protected static function createRuleSet(?string $header = null): RuleSet return new RuleSet\Php80($header); } - protected function expectedCustomFixers(): iterable + protected function expectedCustomFixers(): Fixers { - yield from []; + return Fixers::empty(); } protected function expectedName(): Name diff --git a/test/Unit/RuleSet/Php81Test.php b/test/Unit/RuleSet/Php81Test.php index 081c5fa7..58d8d1fc 100644 --- a/test/Unit/RuleSet/Php81Test.php +++ b/test/Unit/RuleSet/Php81Test.php @@ -14,6 +14,7 @@ namespace Ergebnis\PhpCsFixer\Config\Test\Unit\RuleSet; use Ergebnis\PhpCsFixer\Config\Factory; +use Ergebnis\PhpCsFixer\Config\Fixers; use Ergebnis\PhpCsFixer\Config\Name; use Ergebnis\PhpCsFixer\Config\PhpVersion; use Ergebnis\PhpCsFixer\Config\Rules; @@ -22,6 +23,7 @@ #[Framework\Attributes\CoversClass(RuleSet\Php81::class)] #[Framework\Attributes\UsesClass(Factory::class)] +#[Framework\Attributes\UsesClass(Fixers::class)] #[Framework\Attributes\UsesClass(Name::class)] #[Framework\Attributes\UsesClass(PhpVersion::class)] #[Framework\Attributes\UsesClass(PhpVersion\Major::class)] @@ -35,9 +37,9 @@ protected static function createRuleSet(?string $header = null): RuleSet return new RuleSet\Php81($header); } - protected function expectedCustomFixers(): iterable + protected function expectedCustomFixers(): Fixers { - yield from []; + return Fixers::empty(); } protected function expectedName(): Name diff --git a/test/Unit/RuleSet/Php82Test.php b/test/Unit/RuleSet/Php82Test.php index 3575bb2b..fc06a4eb 100644 --- a/test/Unit/RuleSet/Php82Test.php +++ b/test/Unit/RuleSet/Php82Test.php @@ -14,6 +14,7 @@ namespace Ergebnis\PhpCsFixer\Config\Test\Unit\RuleSet; use Ergebnis\PhpCsFixer\Config\Factory; +use Ergebnis\PhpCsFixer\Config\Fixers; use Ergebnis\PhpCsFixer\Config\Name; use Ergebnis\PhpCsFixer\Config\PhpVersion; use Ergebnis\PhpCsFixer\Config\Rules; @@ -22,6 +23,7 @@ #[Framework\Attributes\CoversClass(RuleSet\Php82::class)] #[Framework\Attributes\UsesClass(Factory::class)] +#[Framework\Attributes\UsesClass(Fixers::class)] #[Framework\Attributes\UsesClass(Name::class)] #[Framework\Attributes\UsesClass(PhpVersion::class)] #[Framework\Attributes\UsesClass(PhpVersion\Major::class)] @@ -35,9 +37,9 @@ protected static function createRuleSet(?string $header = null): RuleSet return new RuleSet\Php82($header); } - protected function expectedCustomFixers(): iterable + protected function expectedCustomFixers(): Fixers { - yield from []; + return Fixers::empty(); } protected function expectedName(): Name