Skip to content

Rector - Instant Upgrades and Automated Refactoring

Rector instantly upgrades and refactors the PHP code of your application.

DrevOps comes with pre-configured Rector configuration for Drupal projects. The configuration is based on the configuration provided by Drupal Rector.


Check for violations

vendor/bin/rector process --dry-run . # Only see the diff of changes, do not save them to files.
ahoy lint-be

Fix violations

vendor/bin/rector process .
ahoy lint-fix


See configuration reference.

All global configuration takes place in the rector.php file.

Targets include custom modules and themes, settings and tests.

Config sets

Rector provides config sets functionality that allows to enable/disable rules in bulk.

DrevOps provides the config sets for Drupal 8 and Drupal 9 deprecated code and code style fixes.

The config sets are meant to be adjusted per-project as needed.

A full list of available config sets can be found in the Rules overview page.

  // Provided by Rector.
  // Provided by Drupal Rector.


See more on Ignoring Rules Or Paths page.

Ignoring rules globally takes place in the rector.php file:


To ignore all Rector rules within a file:


To ignore a specific rule within a file:

  SimplifyIfReturnBoolRector::class => ['file.php'],

Rector does not support ignoring of the code blocks.

Ignoring fail in CI

This tool runs in CI by default and fails the build if there are any violations.

Set DREVOPS_CI_RECTOR_IGNORE_FAILURE environment variable to 1 to ignore failures. The tool will still run and report violations, if any.