Resolve the composer-based set of extension packages in withComposerBased() - #8332
Merged
TomasVotruba merged 1 commit intoAug 10, 2026
Merged
Conversation
…ased()
`withComposerBased(phpunit: true)` and friends load a single set in which every
rule is bound to the installed package version, which is what
`ComposerPackageConstraintInterface` deprecated `SetProviderInterface` and
`ComposerTriggeredSet` in favour of.
The `laravel:` and `drupal:` toggles could not follow, because rector-src does
not require those packages and cannot import their set list class. They were
left on the deprecated set-group path, so an extension that has already migrated
to a composer-based set has no way to be picked up by the toggle that is meant
to load it.
Resolve the extension's set list constant by name instead, so no dependency is
needed:
private const array EXTENSION_COMPOSER_BASED_SET_LISTS = [
SetGroup::LARAVEL => 'RectorLaravel\Set\LaravelSetList::COMPOSER_BASED',
SetGroup::DRUPAL => 'DrupalRector\Set\DrupalSetList::COMPOSER_BASED',
];
When the constant is defined, the set is loaded like the bundled packages' ones.
When it is not — the extension is absent, or has not migrated yet — the set
group is registered exactly as before, so nothing changes for it.
palantirnet/drupal-rector has `DrupalSetList::COMPOSER_BASED` ready on a branch:
every rule is registered with the exact `drupal/core` version its deprecation
was introduced in, so `withComposerBased(drupal: true)` starts loading it as
soon as both are released.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
withComposerBased(phpunit: true),doctrine:,twig:andsymfony:load a single set in which every rule is bound to the installed package version on its own — the patternComposerPackageConstraintInterfacedeprecatedSetProviderInterfaceandComposerTriggeredSetin favour of.The
laravel:anddrupal:toggles could not follow, because rector-src does not require those packages and so cannot import their set list class. They stayed on the deprecated set-group path, which means an extension that has migrated to a composer-based set has no way to be picked up by the very toggle meant to load it.This resolves the extension's set list constant by name, so no dependency is needed:
Constant defined → the set is loaded, exactly like the bundled packages'. Constant absent — extension not installed, or not migrated yet — → the set group is registered as before, so nothing changes for it.
defined()autoloads the class and returnsfalserather than throwing when it does not exist.palantirnet/drupal-rectorhasDrupalSetList::COMPOSER_BASEDready on a branch: a single generated set registering every rule with the exactdrupal/coreversion its deprecation was introduced in, configurable ones throughruleWithConfigurationComposerVersionBound(). With this changewithComposerBased(drupal: true)picks it up as soon as both are released, andrector composer-basedreports the constraints.