feat: composer-based sets + register as rector-extension - #370
Merged
Conversation
bbrala
marked this pull request as draft
June 16, 2026 10:36
Collaborator
Author
|
Initial exploration, some issues need examination, especially the rector.php, but think this is 90% |
Add DrupalSetProvider implementing SetProviderInterface, exposing the
per-minor Drupal deprecation and breaking configs as ComposerTriggeredSets
keyed on drupal/core. Rector loads them automatically from the installed
core version (cumulative-downward via ^version), so a site on 11.4 gets
11.0-11.4 and never a future minor's rules - backward-compatibility safe.
Because the matched version guarantees the replacement symbols exist on the
installed core, the otherwise opt-in breaking sets are folded in.
Set the package type to rector-extension and ship config/extension.php via
extra.rector.includes. Projects that have rector/extension-installer get
Drupal defaults (file extensions, autoloading, upgrade_status skip,
phpstan-drupal) automatically; it loads before the project's rector.php so
the project config keeps precedence, and the bundled rector.php template
stays self-sufficient when the installer is absent. The lookup is guarded
with Composer\InstalledVersions::isInstalled('drupal/core') so it never
throws in non-Drupal contexts. The PHPUnit bootstrap is not auto-loaded and
stays tied to the deprecation sets.
Refs rectorphp/rector#9778
bbrala
force-pushed
the
feat/composer-based-sets
branch
from
June 16, 2026 14:50
6aa7ad5 to
e5741a9
Compare
Contributor
|
I've added few comments. Looks very good to me 👍 |
…ypoint and update the changelog to something more sane
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.
What
Two related changes that let Rector configure Drupal deprecation fixes from the installed
drupal/coreversion.1. Composer-based sets (
DrupalSetProvider)A
SetProviderInterfaceexposing the per-minor deprecation and breaking configs asComposerTriggeredSets keyed ondrupal/core. Enable with:^version: a site on 11.4 loads 11.0→11.4 and never a future minor — inherently BC-safe (only rules for deprecations that are live on the installed core). Verified incl. dev/beta core.drupalgroup.config/drupal-bootstrap.phpset, matched once per major (drupal/core ^10.0/^11.0). The per-minor deprecation configs don't register it (only the aggregated*-all-deprecations.phpsets do), and composer-based selection loads the per-minor configs directly — so the bootstrap is registered separately. Kept apart on purpose: the bootstrap throws without a Drupal install, and composer-based sets only ever load whendrupal/coreis present, so the throw can never fire here.drupal/core10.0–10.3 and 11.0–11.4.2. Register as a
rector-extension(progressive enhancement)type: rector-extension+extra.rector.includesshipsconfig/extension.php, which supplies sensible Drupal defaults (file extensions, autoloading, theupgrade_statusskip, phpstan-drupal). It loads before the project'srector.php, so the project config always wins.The bundled
rector.phptemplate is left unchanged / self-sufficient on purpose — see the testing note below.Why the template wasn't slimmed (empirical finding)
I tested whether the auto-config loads in a real consumer (scratch project, sentinel in
config/extension.php, ranrector --dry-run):extension.phpauto-loaded?rector/rector+drupal-rectorrector/extension-installerSo the auto-config only activates when the consumer has
rector/extension-installer(rector/rectordoesn't pull it in, and Composer silently skips plugins not inallow-plugins). Slimming the template would therefore risk silently dropping.module/.themecoverage for projects without the installer. The template stays the reliable source of truth; the extension is a bonus for projects that have the installer.The same test caught a bug:
DrupalFinderComposerRuntime::getDrupalRoot()throws (Package "drupal/core" is not installed) rather than returning null, so the lookup is now guarded withInstalledVersions::isInstalled('drupal/core')and re-verified to not throw on non-Drupal projects.Upstream dependency
withComposerBased(drupal: true)needs Rector core to shipSetGroup::DRUPAL+ thedrupal:toggle — rectorphp/rector-src#8041. Until then the provider is dormant. Plan per @TomasVotruba: get the provider intomain, then kick off testing upstream.Verification
composer validateOK.DrupalSetProviderTest: 8 tests / 82 assertions incl. the cumulative-matching matrix (deprecation + breaking + bootstrap) and the no-drupal/corecase.