Rector is an automated refactoring and code upgrade tool for PHP that transforms source code according to configurable rules and rule sets.
The tool solves two interconnected problems: keeping PHP applications current with language versions and framework updates, and maintaining consistent code quality as teams grow. Rector works by parsing PHP code into an abstract syntax tree, applying transformations defined by rules or rule sets, and outputting the refactored result. Users can preview changes with a dry-run mode before committing them, and integrate the tool into CI pipelines for continuous automated refactoring.
Rector suits teams upgrading legacy PHP applications or those wanting to enforce code standards automatically. It handles upgrades across the full PHP version range from 5.3 to 8.5, with dedicated rule sets for major frameworks and projects including Symfony, PHPUnit, and Doctrine. The tool is configured through a rector.php file where developers specify which rules or sets to apply, giving fine-grained control over transformations. Teams should adopt it if they need to modernize codebases without manual effort or want to reduce code review burden by automating style and quality checks.
The project maintains active engagement with the broader PHP ecosystem through community-contributed rule sets for specialized frameworks like Drupal, CakePHP, Laravel, TYPO3, Shopware, and others. Development activity shows sustained investment in expanding rule coverage and documentation, with a published book available explaining both internal mechanics and custom rule creation for users needing domain-specific transformations.