[#2975] Replaced versioned Drupal Rector sets with the composer-based set. - #2977
Conversation
… 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.
WalkthroughRector configurations now use Composer-based Drupal rules. Acquia fixtures use ChangesRector configuration alignment
Estimated code review effort: 2 (Simple) | ~10 minutes Mergeability Score: 🟡 Moderate · up to 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: Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
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
📒 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.phprector.php
| // 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) |
There was a problem hiding this comment.
🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick win
🧩 Analysis chain
🏁 Script executed:
find .artifacts -maxdepth 1 -type f -name 'docs-*.md' -printRepository: drevops/vortex
Length of output: 198
🏁 Script executed:
find docs -maxdepth 2 -type f -printRepository: drevops/vortex
Length of output: 244
🏁 Script executed:
git ls-files rector.php .vortex/cli/tests/Fixtures/handler_process/_baseline/rector.phpRepository: drevops/vortex
Length of output: 227
🏁 Script executed:
ls -la .artifactsRepository: 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:
- 1: https://github.com/palantirnet/drupal-rector/
- 2: https://www.drupal.org/about/core/blog/use-rector-on-your-drupal-site-easier-than-ever-with-new-composer-based-sets
- 3: https://packagist.org/packages/palantirnet/drupal-rector
- 4: feat: add drupal to RectorConfigBuilder::withComposerBased rectorphp/rector-src#8041
- 5: https://github.com/rectorphp/rector/releases/tag/2.5.0
🌐 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:
- 1: https://github.com/palantirnet/drupal-rector/
- 2: feat: disable BC wrapping by default for composer-based sets palantirnet/drupal-rector#373
🏁 Script executed:
curl -L --fail --silent --show-error https://raw.githubusercontent.com/palantirnet/drupal-rector/1.1.2/README.mdRepository: drevops/vortex
Length of output: 14763
🏁 Script executed:
cat docs/README.mdRepository: drevops/vortex
Length of output: 657
🏁 Script executed:
cat -n rector.phpRepository: drevops/vortex
Length of output: 6414
🏁 Script executed:
cat -n .vortex/cli/tests/Fixtures/handler_process/_baseline/rector.phpRepository: 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.jsonRepository: 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
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
@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.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
1 similar comment
This comment has been minimized.
This comment has been minimized.
Codecov Report✅ All modified and coverable lines are covered by tests. 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. 🚀 New features to boost your workflow:
|
|
📖 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. |
|
Code coverage (threshold: 90%) Per-class coverage |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
1 similar comment
|
Code coverage (threshold: 90%) Per-class coverage |
Closes #2975
Summary
rector/rector 2.6.2 (published 2026-08-12) removed the versioned
Rector\PHPUnit\Set\PHPUnitSetList::PHPUNIT_40throughPHPUNIT_130constants in favor of composer-based sets, butpalantirnet/drupal-rector1.1.2 still referencesPHPUnitSetList::PHPUNIT_90from its Drupal 8/9/10 deprecation configs, whichrector.phploaded viaDrupal9SetList::DRUPAL_9andDrupal10SetList::DRUPAL_10. Because the template commits no lock file, CI resolved rector/rector 2.6.2 fresh and Rector aborted withUndefined constant Rector\PHPUnit\Set\PHPUnitSetList::PHPUNIT_90before analysing anything, failing thelintandvortex-test-workflowchecks 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 throughpalantirnet/drupal-rector'sDrupalSetProviderand binds each set to the installeddrupal/coreversion instead of a hardcoded major-version list. ThewithComposerBased()call exists in both rector/rector 2.6.1 and 2.6.2, so the fix is safe across the whole^2.6.1constraint 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
->withSets([Drupal9SetList::DRUPAL_9, Drupal10SetList::DRUPAL_10])with->withComposerBased(drupal: TRUE)in the rootrector.php, and removed the now-unusedDrupalRector\Set\Drupal9SetList/DrupalRector\Set\Drupal10SetListimports.composer update-snapshots. That rewrites.vortex/cli/tests/Fixtures/handler_process/_baseline/rector.php, which mirrors the generated project'srector.php, and shifts the stored diff-hunk line offsets in the 15 scenario fixtures under.vortex/cli/tests/Fixtures/handler_process/*/rector.phpthat record their deltas against that baseline.Before / After
Summary by CodeRabbit
Refactor
docrootdirectory.Tests