rector-developer

Create PHP transformation rules that traverse the PHP-Parser AST and return modified nodes.

25|Updated Feb 22, 2026
One-click install
npx skills add https://github.com/peterfox/agent-skills --skill rector-developer-peterfox
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: rector-developer
Source: https://github.com/peterfox/agent-skills/tree/main/rector-developer
Command: npx skills add https://github.com/peterfox/agent-skills --skill rector-developer-peterfox

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Rector rule development automates PHP code transformations by defining rules that traverse the PHP-Parser AST and apply refactor logic safely.

Core Features & Use Cases

  • Provides skeletons and guidance for building Rector rules (getRuleDefinition, getNodeTypes, refactor) and for writing tests and docs.
  • Supports configuring rules (ConfigurableRectorInterface) and PHP version gating (MinPhpVersionInterface) and explains how to register rules in rector.php.
  • Use cases include renaming functions or methods, converting call shapes, or creating new transformation rules across a codebase.

Quick Start

Create a Rector rule class that implements refactor(), configure it if needed, and run your Rector tests to validate the transformation.

Frequently Asked Questions about rector-developer

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I write a custom Rector rule to transform PHP code?

To write a custom Rector rule, create a rule class implementing the refactor() method to traverse the PHP-Parser AST and return modified nodes. You must also define getRuleDefinition() and getNodeTypes() to specify target nodes.

What is a Rector rule and how does it automate PHP refactoring?

A Rector rule automates PHP refactoring by defining transformation logic that traverses the PHP-Parser AST to safely modify code structures like function calls or method names across a codebase without manual edits.

How do I register a new Rector rule in my rector.php configuration?

You register a Rector rule in the rector.php configuration file to activate it during code transformation. Proper registration ensures the rule is loaded and executed alongside other project rules.

Can I configure Rector rules for different PHP versions?

Yes, you can configure Rector rules for specific PHP versions by implementing the MinPhpVersionInterface. This gates the rule so it only applies when the target environment meets the minimum PHP version requirement.

How do I pass configuration options to a Rector rule?

You pass configuration options to a Rector rule by implementing the ConfigurableRectorInterface. This allows the rule to accept parameters during registration in rector.php for dynamic code transformations.

What do I need to know before building Rector rules?

Before building Rector rules, you need to understand Rector's architecture, PHP-Parser node types, and PHPStan type analysis. This knowledge is required to correctly traverse the AST and implement safe code transformation logic.