From 72ec14377279a6b3a3b4be203e29841b6f9c0cf0 Mon Sep 17 00:00:00 2001 From: Benedikt Franke Date: Wed, 4 Nov 2026 16:14:11 +0100 Subject: [PATCH] chore(rector): support PHPUnit sets of rector 1.x and 2.x MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Rector 2.x removed the PHPUNIT_40 to PHPUNIT_110 set constants, so `make rector` failed with an undefined constant after `composer update`. Use `withPreparedSets(phpunitCodeQuality: true)`, which exists in both majors, and `withComposerBased(phpunit: true)` where available, falling back to the version constants on rector 1.x. 🤖 Generated with Claude Code --- rector.php | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/rector.php b/rector.php index 56d17ae..1586af1 100644 --- a/rector.php +++ b/rector.php @@ -1,24 +1,15 @@ withSets([ SetList::CODE_QUALITY, SetList::TYPE_DECLARATION, SetList::RECTOR_PRESET, - PHPUnitSetList::PHPUNIT_40, - PHPUnitSetList::PHPUNIT_50, - PHPUnitSetList::PHPUNIT_60, - PHPUnitSetList::PHPUNIT_70, - PHPUnitSetList::PHPUNIT_80, - PHPUnitSetList::PHPUNIT_90, - PHPUnitSetList::PHPUNIT_100, - PHPUnitSetList::PHPUNIT_110, - PHPUnitSetList::PHPUNIT_CODE_QUALITY, ]) + ->withPreparedSets(phpunitCodeQuality: true) ->withPhpSets() ->withRules([ Rector\PHPUnit\CodeQuality\Rector\Class_\PreferPHPUnitSelfCallRector::class, @@ -40,3 +31,15 @@ __DIR__ . '/vendor/larastan/larastan/extension.neon', __DIR__ . '/vendor/spaze/phpstan-disallowed-calls/extension.neon', ]); + +// TODO remove after the rector/rector constraint drops ^1 +if (method_exists($config, 'withComposerBased')) { + $config = $config->withComposerBased(phpunit: true); +} else { + $config = $config->withSets(array_map( + 'constant', + array_map(fn (int $version): string => 'Rector\PHPUnit\Set\PHPUnitSetList::PHPUNIT_' . $version, [40, 50, 60, 70, 80, 90, 100, 110]), + )); +} + +return $config;