Rector 2.5 Adds Composer-Based Sets for Drupal Code Upgrades
Composer-based Rector sets now support Drupal, giving site maintainers a simpler way to automate version-specific custom code upgrades. A Drupal.org post published on 2 July 2026 by Björn Brala says the feature is available as of Rector 2.5. The post says Rector can inspect a project’s composer.json, detect installed Drupal and dependency versions, and run relevant refactoring sets without manually maintaining version numbers in rector.php.
The change reduces configuration work for maintainers upgrading custom Drupal code. Instead of listing multiple version-specific sets by hand, a project can register the Drupal set provider and enable Composer-based selection. Rector then chooses rules from the versions installed in the project.
The setup uses palantirnet/drupal-rector, which the post says pulls in Rector 2.5 or newer. Björn says two configuration calls handle the Drupal integration: withSetProviders registers the Drupal rules, while withComposerBased(drupal: TRUE) tells Rector to select those rules from the installed project versions. Maintainers can then run vendor/bin/rector process against custom modules and themes and review the resulting diff.
Rector reads the installed drupal/core version and loads all rule sets up to and including that minor release. A site on Drupal 11.4 loads the Drupal 11.0 to 11.4 rules, while a site on Drupal 11.2 loads the Drupal 11.0 to 11.2 rules. When the site upgrades core, the selected rules move with it, so maintainers do not need to update rector.php for each new Drupal minor.
The Drupal.org post says the feature was backed by recent Drupal Rector 1.0.0 beta releases, while the Composer-based sets landed in Rector 2.5.0. Björn connects the change to Drupal 12 readiness work, noting that the refreshed Project Update Bot pushed automated deprecation coverage past 80%. He also says the rules are tested against nearly 10,000 contributed modules, giving maintainers a larger surface for checking automated transformations.
Drupal rules are expected to appear later on getrector.com/find-rule, Rector’s searchable catalogue of available rules. The post asks maintainers to try the setup on real custom code, inspect the changes, and report cases where transformations are incorrect or incomplete. Björn also credits Rector author Tomas Votruba for collaboration on the feature.


