Skip to content

[#2975] Replaced versioned Drupal Rector sets with the composer-based set. - #2977

Merged
AlexSkrypnyk merged 3 commits into
2.xfrom
feature/fix-rector-sets
Aug 13, 2026
Merged

[#2975] Replaced versioned Drupal Rector sets with the composer-based set.#2977
AlexSkrypnyk merged 3 commits into
2.xfrom
feature/fix-rector-sets

Conversation

@AlexSkrypnyk

@AlexSkrypnyk AlexSkrypnyk commented Aug 13, 2026

Copy link
Copy Markdown
Member

Closes #2975

Summary

rector/rector 2.6.2 (published 2026-08-12) removed the versioned Rector\PHPUnit\Set\PHPUnitSetList::PHPUNIT_40 through PHPUNIT_130 constants in favor of composer-based sets, but palantirnet/drupal-rector 1.1.2 still references PHPUnitSetList::PHPUNIT_90 from its Drupal 8/9/10 deprecation configs, which rector.php loaded via Drupal9SetList::DRUPAL_9 and Drupal10SetList::DRUPAL_10. Because the template commits no lock file, CI resolved rector/rector 2.6.2 fresh and Rector aborted with Undefined constant Rector\PHPUnit\Set\PHPUnitSetList::PHPUNIT_90 before analysing anything, failing the lint and vortex-test-workflow checks on every branch regardless of what changed in that branch. This replaces the two versioned set lists with ->withComposerBased(drupal: TRUE), which loads Drupal sets through palantirnet/drupal-rector's DrupalSetProvider and binds each set to the installed drupal/core version instead of a hardcoded major-version list. The withComposerBased() call exists in both rector/rector 2.6.1 and 2.6.2, so the fix is safe across the whole ^2.6.1 constraint range; the tradeoff is that Drupal 9 and 10 deprecation rules no longer run against a Drupal 11 site, which is the intended behavior of the composer-based provider rather than a regression.

Changes

  • Replaced ->withSets([Drupal9SetList::DRUPAL_9, Drupal10SetList::DRUPAL_10]) with ->withComposerBased(drupal: TRUE) in the root rector.php, and removed the now-unused DrupalRector\Set\Drupal9SetList / DrupalRector\Set\Drupal10SetList imports.
  • Regenerated the installer snapshot fixtures with composer update-snapshots. That rewrites .vortex/cli/tests/Fixtures/handler_process/_baseline/rector.php, which mirrors the generated project's rector.php, and shifts the stored diff-hunk line offsets in the 15 scenario fixtures under .vortex/cli/tests/Fixtures/handler_process/*/rector.php that record their deltas against that baseline.

Before / After

BEFORE
┌───────────────────────────────────────┐
│ rector.php                            │
│ ->withSets([Drupal9SetList::DRUPAL_9, │
│  Drupal10SetList::DRUPAL_10])         │
└───────────────────────────────────────┘
        │
        ▼
┌─────────────────────────────────────────────────────────┐
│ palantirnet/drupal-rector Drupal 8/9/10 configs         │
│ reference Rector\PHPUnit\Set\PHPUnitSetList::PHPUNIT_90 │
└─────────────────────────────────────────────────────────┘
        │
        ▼
┌──────────────────────────────────────────────────────┐
│ PHPUNIT_90 removed in rector/rector 2.6.2            │
│ FATAL: Undefined constant PHPUnitSetList::PHPUNIT_90 │
│ Rector aborts before analysing any file              │
└──────────────────────────────────────────────────────┘

Result: lint and vortex-test-workflow fail on every branch

AFTER
┌───────────────────────────────────┐
│ rector.php                        │
│ ->withComposerBased(drupal: TRUE) │
└───────────────────────────────────┘
        │
        ▼
┌───────────────────────────────────────────────────┐
│ palantirnet/drupal-rector DrupalSetProvider binds │
│ each set to the installed drupal/core version     │
│ (ComposerTriggeredSet)                            │
└───────────────────────────────────────────────────┘
        │
        ▼
┌─────────────────────────────────────────────────────┐
│ drupal/core 11.4.5 resolves to the Drupal 11.0-11.4 │
│ sets plus matching breaking-change sets;            │
│ Drupal 9/10 configs (and PHPUNIT_90) never load     │
└─────────────────────────────────────────────────────┘
        │
        ▼
┌────────────────────────────────────┐
│ Rector completes analysis normally │
│ dry-run exits 0                    │
└────────────────────────────────────┘

Result: lint and vortex-test-workflow pass

Summary by CodeRabbit

  • Refactor

    • Updated code-quality configuration to detect applicable Drupal rules from the project’s Composer metadata.
    • Adjusted Acquia project paths to use the docroot directory.
    • Simplified analysis scope by excluding custom theme directories where appropriate.
    • Removed optional Behat and PHPUnit transformations when those tools are not enabled.
  • Tests

    • Updated configuration fixtures to reflect the revised Drupal detection, project paths, and tool-specific behavior.

… set.

'rector/rector' 2.6.2 removed the versioned 'PHPUnitSetList::PHPUNIT_40' through 'PHPUNIT_130' constants in favour of composer-based sets. The 'palantirnet/drupal-rector' Drupal 8, 9 and 10 deprecation configs still reference 'PHPUnitSetList::PHPUNIT_90', so loading 'Drupal9SetList::DRUPAL_9' or 'Drupal10SetList::DRUPAL_10' aborts Rector before it analyses anything.

'withComposerBased(drupal: TRUE)' loads Drupal sets through 'DrupalSetProvider', which binds each set to a 'drupal/core' version and loads only those the installed core satisfies. On Drupal 11 that resolves to the 11.0-11.4 sets and never the Drupal 9 or 10 configs that carry the removed constant.
@coderabbitai

coderabbitai Bot commented Aug 13, 2026

Copy link
Copy Markdown

Review Change Stack

Walkthrough

Rector configurations now use Composer-based Drupal rules. Acquia fixtures use docroot paths. Other fixtures exclude custom themes and selected Behat or PHPUnit transformations.

Changes

Rector configuration alignment

Layer / File(s) Summary
Composer-based Drupal rules
rector.php, .vortex/cli/tests/Fixtures/handler_process/_baseline/rector.php
Replaced explicit Drupal 9 and Drupal 10 sets with withComposerBased(drupal: TRUE).
Acquia docroot paths
.vortex/cli/tests/Fixtures/handler_process/hosting_acquia/rector.php, .vortex/cli/tests/Fixtures/handler_process/hosting_project_name___acquia/rector.php
Updated Rector paths and skipped include globs from web to docroot.
Fixture rule scopes
.vortex/cli/tests/Fixtures/handler_process/*/rector.php
Removed custom theme paths and selected Behat and PHPUnit Rector rules from fixture configurations.

Estimated code review effort: 2 (Simple) | ~10 minutes

Mergeability Score: 🟡 Moderate · up to 199e5

The change switches Drupal rule loading to composer-based sets, but the required provider is not registered in the main and generated configurations. Rector may fail to resolve the sets and block lint or generated-project checks, so this should be fixed before merging.

Possibly related PRs

Suggested labels: Needs review

Poem

A rabbit hops through Rector’s rules,
Composer guides the way.
docroot paths replace old trails,
While unused rules decay.
The fixtures now align and stay.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes replacing versioned Drupal Rector sets with the composer-based set.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feature/fix-rector-sets

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@rector.php`:
- Around line 102-105: Import DrupalRector\Set\DrupalSetProvider and register
DrupalSetProvider::class via withSetProviders in both rector.php (lines 102-105)
and .vortex/cli/tests/Fixtures/handler_process/_baseline/rector.php (lines
100-103), alongside the existing withComposerBased(drupal: TRUE) configuration.
🪄 Autofix

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: ad2edee6-de68-4730-b1fe-15985b4172cd

📥 Commits

Reviewing files that changed from the base of the PR and between 2813c7b and 199e5c0.

📒 Files selected for processing (17)
  • .vortex/cli/tests/Fixtures/handler_process/_baseline/rector.php
  • .vortex/cli/tests/Fixtures/handler_process/hosting_acquia/rector.php
  • .vortex/cli/tests/Fixtures/handler_process/hosting_project_name___acquia/rector.php
  • .vortex/cli/tests/Fixtures/handler_process/theme_claro/rector.php
  • .vortex/cli/tests/Fixtures/handler_process/theme_olivero/rector.php
  • .vortex/cli/tests/Fixtures/handler_process/theme_stark/rector.php
  • .vortex/cli/tests/Fixtures/handler_process/tools_groups_no_be_tests/rector.php
  • .vortex/cli/tests/Fixtures/handler_process/tools_groups_no_be_tests_circleci/rector.php
  • .vortex/cli/tests/Fixtures/handler_process/tools_groups_no_fe_lint_no_theme/rector.php
  • .vortex/cli/tests/Fixtures/handler_process/tools_groups_no_fe_lint_no_theme_circleci/rector.php
  • .vortex/cli/tests/Fixtures/handler_process/tools_no_behat/rector.php
  • .vortex/cli/tests/Fixtures/handler_process/tools_no_behat_circleci/rector.php
  • .vortex/cli/tests/Fixtures/handler_process/tools_no_eslint_no_theme/rector.php
  • .vortex/cli/tests/Fixtures/handler_process/tools_no_phpunit/rector.php
  • .vortex/cli/tests/Fixtures/handler_process/tools_no_phpunit_circleci/rector.php
  • .vortex/cli/tests/Fixtures/handler_process/tools_no_stylelint_no_theme/rector.php
  • rector.php

Comment thread rector.php
Comment on lines +102 to +105
// Drupal-specific deprecation fixes. Each rule is bound to a `drupal/core`
// version and runs only when the installed core matches, so the set tracks
// core upgrades without changing this configuration.
->withComposerBased(drupal: TRUE)

@coderabbitai coderabbitai Bot Aug 13, 2026

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

find .artifacts -maxdepth 1 -type f -name 'docs-*.md' -print

Repository: drevops/vortex

Length of output: 198


🏁 Script executed:

find docs -maxdepth 2 -type f -print

Repository: drevops/vortex

Length of output: 244


🏁 Script executed:

git ls-files rector.php .vortex/cli/tests/Fixtures/handler_process/_baseline/rector.php

Repository: drevops/vortex

Length of output: 227


🏁 Script executed:

ls -la .artifacts

Repository: drevops/vortex

Length of output: 210


🌐 Web query:

Drupal Rector 1.1.2 withComposerBased drupal DrupalSetProvider withSetProviders

💡 Result:

In Drupal Rector 1.1.2, you can use the withComposerBased and withSetProviders methods to automate the selection of Drupal upgrade rules based on your installed drupal/core version, eliminating the need to manually manage lists of upgrade sets [1][2][3]. To implement this, update your rector.php configuration file as follows [2]: return RectorConfig::configure ->withSetProviders(\DrupalRector\Set\DrupalSetProvider::class) ->withComposerBased(drupal: true); By using this configuration: 1. withSetProviders(\DrupalRector\Set\DrupalSetProvider::class) registers the Drupal-specific rule sets [2][4]. 2. withComposerBased(drupal: true) instructs Rector to inspect your project's composer.json, identify the installed version of drupal/core, and automatically load the relevant upgrade rules up to and including that minor version [1][2]. This approach is dynamic; as you upgrade your Drupal core version, Rector will automatically adjust the sets it applies without requiring further manual updates to your rector.php [2]. This feature requires Rector 2.5.0 or newer [2][5].

Citations:


🌐 Web query:

site:github.com/palantirnet/drupal-rector "withComposerBased" "DrupalSetProvider"

💡 Result:

The withComposerBased method is a feature of the drupal-rector project, used to automatically select and apply Rector deprecation sets based on the version of drupal/core installed in your project [1][2]. Usage: To use this feature, you must register the DrupalSetProvider and configure the withComposerBased option in your rector.php file [1]: return RectorConfig::configure ->withSetProviders(\DrupalRector\Set\DrupalSetProvider::class) ->withComposerBased(drupal: true); How it works: When configured this way, Rector inspects your project's installed drupal/core version [1]. It then automatically loads the relevant deprecation sets for all Drupal minor versions up to and including your current installed version [1]. For example, if your site is on Drupal 11.2, it will load sets covering 11.0 through 11.2, while excluding future minor versions [1]. Key benefits: - Version Accuracy: It ensures that your code is only updated for deprecations relevant to your specific Drupal installation, preventing the application of premature or unnecessary rules [1][2]. - Automatic Breaking Changes: Because the exact version is known, Rector can safely include "breaking" sets (rules for renames introduced in specific minor versions) that would otherwise be unsafe to apply without version awareness [1]. - Simplified Configuration: It removes the need to manually list or update deprecation sets in your configuration as you upgrade your Drupal core [1]. Important Note: This feature typically requires a compatible version of the rector package that supports the SetGroup::DRUPAL constant and the withComposerBased toggle [1][2]. As it is designed for your specific installed version, it is intended for projects that do not need to maintain simultaneous compatibility with multiple older Drupal versions [2].

Citations:


🏁 Script executed:

curl -L --fail --silent --show-error https://raw.githubusercontent.com/palantirnet/drupal-rector/1.1.2/README.md

Repository: drevops/vortex

Length of output: 14763


🏁 Script executed:

cat docs/README.md

Repository: drevops/vortex

Length of output: 657


🏁 Script executed:

cat -n rector.php

Repository: drevops/vortex

Length of output: 6414


🏁 Script executed:

cat -n .vortex/cli/tests/Fixtures/handler_process/_baseline/rector.php

Repository: drevops/vortex

Length of output: 6366


🏁 Script executed:

rg -n -i 'drupal-rector|rector/rector|withComposerBased|DrupalSetProvider' --glob 'composer*.json' --glob 'rector.php' --glob '*.lock'

Repository: drevops/vortex

Length of output: 152


🏁 Script executed:

git ls-files '*composer*'

Repository: drevops/vortex

Length of output: 5453


🏁 Script executed:

rg -n -i 'rector|drupal-rector' composer.json .vortex/cli/composer.json .vortex/cli/tests/Fixtures/handler_process/_baseline/composer.json

Repository: drevops/vortex

Length of output: 776


Register DrupalSetProvider in both Rector configurations.

withComposerBased(drupal: TRUE) requires DrupalRector\Set\DrupalSetProvider. Add the import and ->withSetProviders(DrupalSetProvider::class) to rector.php and .vortex/cli/tests/Fixtures/handler_process/_baseline/rector.php.

📍 Affects 2 files
  • rector.php#L102-L105 (this comment)
  • .vortex/cli/tests/Fixtures/handler_process/_baseline/rector.php#L100-L103
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@rector.php` around lines 102 - 105, Import DrupalRector\Set\DrupalSetProvider
and register DrupalSetProvider::class via withSetProviders in both rector.php
(lines 102-105) and
.vortex/cli/tests/Fixtures/handler_process/_baseline/rector.php (lines 100-103),
alongside the existing withComposerBased(drupal: TRUE) configuration.

Source: MCP tools

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Correct, and thank you - this was a real bug, not a style nit. Verified with vendor/bin/rector list-rules: 0 DrupalRector rules loaded without the provider, 98 with it. withComposerBased(drupal: TRUE) only pushes SetGroup::DRUPAL onto $setGroups; nothing supplies sets for that group unless DrupalSetProvider is registered, so Rector loaded no Drupal rules at all and still exited 0. Lint was green while covering nothing.

This pull request was merged before the fix could land here, so it is in #2979 instead, which adds ->withSetProviders(DrupalSetProvider::class) to both rector.php and the regenerated _baseline/rector.php fixture.

One consequence worth recording: registering the provider loads the Drupal 11.0-11.4 sets for the installed drupal/core 11.4.5, which newly enables PhpUnitAddRunTestsInSeparateProcessesAttributeRector from the 11.4 set. That adds #[RunTestsInSeparateProcesses] to the 8 example Kernel and Functional test classes, so those are updated in #2979 as well.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@AlexSkrypnyk, thank you for the detailed verification.

The finding is valid. withComposerBased(drupal: TRUE) alone did not load Drupal rule sets. The green Rector exit status was therefore not sufficient validation.

#2979 contains the required provider registration and the related Drupal 11.4 test-class updates. The PhpUnitAddRunTestsInSeparateProcessesAttributeRector effect is also clear.

🐇 ✓


✏️ Learnings added
Learnt from: AlexSkrypnyk
Repo: drevops/vortex PR: 2977
File: rector.php:102-105
Timestamp: 2026-08-13T01:49:05.251Z
Learning: In this Drupal Rector configuration, `RectorConfig::withComposerBased(drupal: TRUE)` only adds `SetGroup::DRUPAL`; it does not supply Drupal sets. `rector.php` and `.vortex/cli/tests/Fixtures/handler_process/_baseline/rector.php` must also register `DrupalRector\Set\DrupalSetProvider::class` with `withSetProviders()` or no `DrupalRector` rules load, even though Rector exits with status 0.

Learnt from: AlexSkrypnyk
Repo: drevops/vortex PR: 2977
File: rector.php:102-105
Timestamp: 2026-08-13T01:49:05.251Z
Learning: With installed `drupal/core` version 11.4.5, registering `DrupalRector\Set\DrupalSetProvider` loads Drupal 11.0 through 11.4 sets. The Drupal 11.4 set enables `PhpUnitAddRunTestsInSeparateProcessesAttributeRector`, which adds `#[RunTestsInSeparateProcesses]` to the project example Kernel and Functional test classes.

Note: Learnings are effective only in the context of similar code segments. To apply general coding guidelines, please configure review instructions. You can manage existing learnings in the app.

You are interacting with an AI system.

@github-actions

This comment has been minimized.

@AlexSkrypnyk

This comment has been minimized.

1 similar comment
@AlexSkrypnyk

This comment has been minimized.

@codecov

codecov Bot commented Aug 13, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 87.66%. Comparing base (2813c7b) to head (54549ae).

Additional details and impacted files
@@           Coverage Diff           @@
##              2.x    #2977   +/-   ##
=======================================
  Coverage   87.66%   87.66%           
=======================================
  Files         104      104           
  Lines        5563     5563           
  Branches        3        3           
=======================================
  Hits         4877     4877           
  Misses        686      686           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@github-actions

github-actions Bot commented Aug 13, 2026

Copy link
Copy Markdown

📖 Documentation preview for this pull request has been deployed to Netlify:

https://6a7d1a2006282349d37b8ad8--vortex-docs.netlify.app

This preview is rebuilt on every commit and is not the production documentation site.

@github-actions

Copy link
Copy Markdown

Code coverage (threshold: 90%)

  Classes: 100.00% (1/1)
  Methods: 100.00% (2/2)
  Lines:   100.00% (153/153)
Per-class coverage
Drupal\ys_demo\Plugin\Block\CounterBlock
  Methods: 100.00% ( 2/ 2)   Lines: 100.00% ( 10/ 10)

@AlexSkrypnyk

This comment has been minimized.

@AlexSkrypnyk

This comment has been minimized.

1 similar comment
@AlexSkrypnyk

Copy link
Copy Markdown
Member Author

Code coverage (threshold: 90%)

  Classes: 100.00% (1/1)
  Methods: 100.00% (2/2)
  Lines:   100.00% (153/153)
Per-class coverage
Drupal\ys_demo\Plugin\Block\CounterBlock
  Methods: 100.00% ( 2/ 2)   Lines: 100.00% ( 10/ 10)

@AlexSkrypnyk
AlexSkrypnyk merged commit ff7fd63 into 2.x Aug 13, 2026
39 checks passed
@AlexSkrypnyk
AlexSkrypnyk deleted the feature/fix-rector-sets branch August 13, 2026 01:18
@github-project-automation github-project-automation Bot moved this from BACKLOG to Release queue in Vortex 1.x Aug 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Release queue

Development

Successfully merging this pull request may close these issues.

1 participant