Skip to content

feat: disable BC wrapping by default for composer-based sets - #373

Merged
bbrala merged 1 commit into
mainfrom
composer-sets-disable-bc
Jun 18, 2026
Merged

feat: disable BC wrapping by default for composer-based sets#373
bbrala merged 1 commit into
mainfrom
composer-sets-disable-bc

Conversation

@bbrala

@bbrala bbrala commented Jun 18, 2026

Copy link
Copy Markdown
Collaborator

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 installed drupal/core version. The rewritten code therefore only ever runs against that one version — there's no older minor to stay compatible with, so the DeprecationHelper::backwardsCompatibleCall() wrappers are pure noise on that path.

Previously nothing registered the DrupalRectorSettings singleton 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 DrupalRectorSettings singleton with disableBackwardCompatibility() in config/drupal-bootstrap.php — the set already matched once per Drupal major by DrupalSetProvider, so it's the right place and cardinality. A project that does need the wrappers can re-register the singleton in its own rector.php.

Notes

  • Still inert until a Rector release ships SetGroup::DRUPAL and the withComposerBased(drupal: ...) toggle (same as the rest of the composer-based groundwork).
  • CHANGELOG note added under [Unreleased].

Verification

  • PHPUnit: 659 tests, 898 assertions — pass.
  • PHPStan: 221 files — no errors.
  • DrupalSetProviderTest: 8 tests — pass (set file path/matching unchanged).

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.
@bbrala
bbrala merged commit ac22c3c into main Jun 18, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant