feat: disable BC wrapping by default for composer-based sets - #373
Merged
Conversation
Composer-based selection pins the rules to the exact installed Drupal version and only loads sets for deprecations that are live on it, so the rewritten code only ever runs against that one version — there is no older minor to stay compatible with. The DeprecationHelper BC wrappers are therefore pure noise on that path. Register the DrupalRectorSettings singleton with backward-compatibility disabled in config/drupal-bootstrap.php, the set already matched once per Drupal major by DrupalSetProvider. A project that does need the wrappers can re-register the singleton in its own rector.php.
This was referenced Jun 19, 2026
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.
Follow-up to the composer-based sets groundwork shipped in 1.0.0-beta2 (#370, #372).
Why
Under composer-based selection (
withSetProviders(DrupalSetProvider::class)+withComposerBased(drupal: true)), Rector loads only the sets for deprecations that are live on the exact installeddrupal/coreversion. The rewritten code therefore only ever runs against that one version — there's no older minor to stay compatible with, so theDeprecationHelper::backwardsCompatibleCall()wrappers are pure noise on that path.Previously nothing registered the
DrupalRectorSettingssingleton on the composer-based path, so it fell back to the class default (BC enabled) — the opposite of what makes sense there.What
Register the
DrupalRectorSettingssingleton withdisableBackwardCompatibility()inconfig/drupal-bootstrap.php— the set already matched once per Drupal major byDrupalSetProvider, so it's the right place and cardinality. A project that does need the wrappers can re-register the singleton in its ownrector.php.Notes
SetGroup::DRUPALand thewithComposerBased(drupal: ...)toggle (same as the rest of the composer-based groundwork).[Unreleased].Verification
DrupalSetProviderTest: 8 tests — pass (set file path/matching unchanged).