Skip to content

[Configuration] Load single composer-based PHPUnit set in withComposerBased() - #8255

Merged
TomasVotruba merged 1 commit into
mainfrom
phpunit-composer-based-set
Jul 31, 2026
Merged

[Configuration] Load single composer-based PHPUnit set in withComposerBased()#8255
TomasVotruba merged 1 commit into
mainfrom
phpunit-composer-based-set

Conversation

@TomasVotruba

Copy link
Copy Markdown
Member

withComposerBased(phpunit: true) went through the set group machinery: SetGroup::PHPUNIT -> SetProviderCollector -> SetManager::matchBySetGroups() -> installed package resolving -> every matching phpunit40.php ... phpunit130.php set plus composer-based.php.

The composer-based.php set already binds each rule and rule configuration to the installed phpunit/phpunit version on its own, via ComposerPackageConstraintInterface and ruleWithConfigurationComposerVersionBound(). So the group lookup and the per-version sets are not needed - a single set include is enough.

 $setMap = [
     SetGroup::TWIG => $twig,
     SetGroup::DOCTRINE => $doctrine,
-    SetGroup::PHPUNIT => $phpunit,
     SetGroup::SYMFONY => $symfony,
     ...
 ];

+if ($phpunit) {
+    $this->sets[] = PHPUnitSetList::COMPOSER_BASED;
+}

Behavior for the user stays the same:

return RectorConfig::configure()
    ->withComposerBased(phpunit: true);
 final class SomeTest extends TestCase
 {
-    /**
-     * @dataProvider provideData
-     */
+    #[\PHPUnit\Framework\Attributes\DataProvider('provideData')]
     public function test(): void
     {
     }
 }

@TomasVotruba
TomasVotruba merged commit 104c4d6 into main Jul 31, 2026
64 checks passed
@TomasVotruba
TomasVotruba deleted the phpunit-composer-based-set branch July 31, 2026 21:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant