create-rector-config

Generate a Rector configuration for PHP projects, creating a rector.php file that includes PHP upgrade rule sets, code quality rules, dead-code removal, and framework-specific migrations.

Last repository push
GitHub Stars
109
Forks
26
Issues / PRs
1

Installation

Review the source and dependencies with a prompt. A package is available to download.

Install with an AI assistant

Copy the prompt so your assistant can review the pinned revision and dependencies first.

View promptHide prompt
Check whether SkillPI Skill Finder is installed for your current agent. If it is missing, install and enable it using the official instructions at https://github.com/Findskills/skillpi. Then use Skill Finder to locate and install "create-rector-config" from this exact SkillPI detail page: https://skillpi.com/skills/deepskill-04487402bf65c4ed25de9a3567482318410d65797a4f0ccd6a21e4d7292c962f. Verify the upstream source and version against https://github.com/dykyi-roman/awesome-claude-code before installing. If they do not match, stop and report the mismatch. Report the installed path and source version.

Source and setup

github.com

Setup guidance pending

See the original source for supported tools, dependencies, and permissions.

Installation test pending

Generate a Rector configuration for PHP projects, creating a rector.php file that includes PHP upgrade rule sets, code quality rules, dead-code removal, and framework-specific migrations.

0 Downloads

Introduction source: third_party · dykyi-roman · 0.0.1 Reference

SkillPi interpretation

Tasks
Generates Rector configurations for PHP projects. Creates rector.php with PHP upgrade sets, code quality rules, dead code removal, and framework-specific migrations.
Inputs and outputs
vendor/bin/rector process --dry-run --output-format=json ```
Testing
Not tested

Browse files

Browse files at the source ↗

Original SKILL.md

Open original ↗
Frontmatter
name: create-rector-config
description: Generates Rector configurations for PHP projects. Creates rector.php with PHP upgrade sets, code quality rules, dead code removal, and framework-specific migrations.

Rector Configuration Generator

Generates optimized Rector configurations for automated PHP refactoring.

Targets Rector 2.x (rector/rector: ^2.0) — always the RectorConfig::configure() builder, never the legacy return static function (RectorConfig $rectorConfig): void {} closure with ->import()/->sets().

Generated Files

rector.php                # Main configuration

Configuration by Use Case

PHP Version Upgrade

<?php
// rector.php

declare(strict_types=1);

use Rector\Config\RectorConfig;

return RectorConfig::configure()
    ->withPaths([
        __DIR__ . '/src',
        __DIR__ . '/tests',
    ])
    ->withSkip([
        __DIR__ . '/src/Infrastructure/Legacy',
        __DIR__ . '/src/Infrastructure/Migrations',
    ])
    // PHP 8.4 upgrade
    ->withPhpSets(php84: true)
    // Prepared sets
    ->withPreparedSets(
        deadCode: true,
        codeQuality: true,
        typeDeclarations: true,
    );

Code Quality Focus

<?php
// rector.php

declare(strict_types=1);

use Rector\Config\RectorConfig;

return RectorConfig::configure()
    ->withPaths([
        __DIR__ . '/src',
    ])
    ->withPhpSets(php84: true)
    ->withPreparedSets(
        deadCode: true,
        codeQuality: true,
        codingStyle: true,
        typeDeclarations: true,
        privatization: true,
        naming: true,
        instanceOf: true,
        earlyReturn: true,
        strictBooleans: true,
    );

PHPUnit Migration

<?php
// rector.php

declare(strict_types=1);

use Rector\Config\RectorConfig;

return RectorConfig::configure()
    ->withPaths([
        __DIR__ . '/tests',
    ])
    ->withPhpSets(php84: true)
    // Picks the PHPUnit version sets matching composer.json (PHPUnit 10/11/12)
    ->withComposerBased(phpunit: true)
    ->withAttributesSets(phpunit: true)
    ->withPreparedSets(
        phpunitCodeQuality: true,
    );

Symfony Migration

<?php
// rector.php

declare(strict_types=1);

use Rector\Config\RectorConfig;

return RectorConfig::configure()
    ->withPaths([
        __DIR__ . '/src',
        __DIR__ . '/tests',
    ])
    ->withPhpSets(php84: true)
    // Picks Symfony/Doctrine version sets matching composer.json
    ->withComposerBased(symfony: true, doctrine: true)
    ->withAttributesSets(symfony: true, doctrine: true)
    ->withPreparedSets(
        symfonyCodeQuality: true,
        doctrineCodeQuality: true,
    )
    ->withSymfonyContainerXml(__DIR__ . '/var/cache/dev/App_KernelDevDebugContainer.xml');

DDD Project Configuration

<?php
// rector.php

declare(strict_types=1);

use Rector\Config\RectorConfig;
use Rector\DeadCode\Rector\ClassMethod\RemoveUnusedPrivateMethodRector;
use Rector\TypeDeclaration\Rector\ClassMethod\ReturnTypeFromStrictNativeCallRector;
use Rector\TypeDeclaration\Rector\ClassMethod\ReturnTypeFromStrictScalarReturnExprRector;

return RectorConfig::configure()
    ->withPaths([
        __DIR__ . '/src/Domain',
        __DIR__ . '/src/Application',
        __DIR__ . '/src/Infrastructure',
        __DIR__ . '/src/Api',
    ])
    ->withSkip([
        __DIR__ . '/src/Infrastructure/Migrations',
        __DIR__ . '/src/Infrastructure/Legacy',

        // Skip certain rules for specific paths
        RemoveUnusedPrivateMethodRector::class => [
            __DIR__ . '/src/Domain/*/Event/*',  // Event handlers may seem unused
        ],
    ])
    ->withPhpSets(php84: true)
    ->withPreparedSets(
        deadCode: true,
        codeQuality: true,
        typeDeclarations: true,
        privatization: true,
        earlyReturn: true,
    )
    // Strict for Domain layer
    ->withRules([
        ReturnTypeFromStrictNativeCallRector::class,
        ReturnTypeFromStrictScalarReturnExprRector::class,
    ]);

Available Set Lists

PHP Version Sets

->withPhpSets(
    php53: true,  // PHP 5.3 features
    php54: true,  // PHP 5.4 features
    php55: true,  // ...
    php56: true,
    php70: true,
    php71: true,
    php72: true,
    php73: true,
    php74: true,
    php80: true,
    php81: true,
    php82: true,
    php83: true,
    php84: true,  // Latest
)

Quality Sets

use Rector\Set\ValueObject\SetList;

->withSets([
    SetList::CODE_QUALITY,          // General code quality
    SetList::CODING_STYLE,          // Coding style improvements
    SetList::DEAD_CODE,             // Remove dead code
    SetList::EARLY_RETURN,          // Early return patterns
    SetList::PRIVATIZATION,         // Privatize where possible
    SetList::TYPE_DECLARATION,      // Add type declarations
    SetList::INSTANCEOF,            // Instanceof improvements
    SetList::STRICT_BOOLEANS,       // Strict boolean comparisons
])

Framework Sets

// Symfony
use Rector\Symfony\Set\SymfonySetList;
SymfonySetList::SYMFONY_60
SymfonySetList::SYMFONY_70
SymfonySetList::SYMFONY_CODE_QUALITY
SymfonySetList::ANNOTATIONS_TO_ATTRIBUTES

// Doctrine
use Rector\Doctrine\Set\DoctrineSetList;
DoctrineSetList::DOCTRINE_ORM_29
DoctrineSetList::DOCTRINE_CODE_QUALITY
DoctrineSetList::ANNOTATIONS_TO_ATTRIBUTES

// PHPUnit
use Rector\PHPUnit\Set\PHPUnitSetList;
PHPUnitSetList::PHPUNIT_100
PHPUnitSetList::PHPUNIT_CODE_QUALITY
PHPUnitSetList::ANNOTATIONS_TO_ATTRIBUTES

Skip Configuration

Skip Paths

->withSkip([
    __DIR__ . '/src/Legacy/*',
    __DIR__ . '/src/Infrastructure/Migrations/*',
    __DIR__ . '/var/*',
    __DIR__ . '/vendor/*',
])

Skip Rules

use Rector\DeadCode\Rector\ClassMethod\RemoveUnusedPrivateMethodRector;
use Rector\Privatization\Rector\Class_\FinalizeClassesWithoutChildrenRector;

->withSkip([
    // Skip globally
    RemoveUnusedPrivateMethodRector::class,

    // Skip for specific files
    FinalizeClassesWithoutChildrenRector::class => [
        __DIR__ . '/src/Domain/*/Entity/*',
    ],
])

CI Integration

Dry Run (Preview)

# Preview changes without applying
vendor/bin/rector process --dry-run

# Output diff format
vendor/bin/rector process --dry-run --output-format=json

GitHub Actions

rector:
  runs-on: ubuntu-latest
  steps:
    - uses: actions/checkout@v4
    - uses: shivammathur/setup-php@v2
      with:
        php-version: '8.4'
    - run: composer install
    - name: Check Rector
      run: vendor/bin/rector process --dry-run --ansi

    # Optional: Auto-fix in PR
    - name: Apply Rector
      if: github.event_name == 'pull_request'
      run: |
        vendor/bin/rector process
        git diff --quiet || (git add -A && git commit -m "Apply Rector fixes")

GitLab CI

rector:
  script:
    - vendor/bin/rector process --dry-run
  allow_failure: true

rector:fix:
  script:
    - vendor/bin/rector process
    - git diff --quiet || exit 1
  rules:
    - if: $CI_PIPELINE_SOURCE == "merge_request_event"

Common Transformations

PHP 8.4 Features

// Before: Null coalescing
$value = isset($array['key']) ? $array['key'] : 'default';

// After: Null coalescing operator
$value = $array['key'] ?? 'default';

// Before: Constructor property promotion
class User {
    private string $name;

    public function __construct(string $name) {
        $this->name = $name;
    }
}

// After: Property promotion
class User {
    public function __construct(
        private string $name,
    ) {}
}

Dead Code Removal

// Removes:
// - Unused private methods
// - Unused private properties
// - Unreachable code after return/throw
// - Empty methods that do nothing
// - Unused parameters (configurable)

Type Declarations

// Adds return types from:
// - Strict native calls (strlen, count, etc.)
// - Scalar return expressions
// - Property types from constructor

// Before
public function getName() {
    return $this->name;
}

// After
public function getName(): string {
    return $this->name;
}

Generation Instructions

  1. Analyze project:

    • Check current PHP version
    • Check target PHP version
    • Identify frameworks (Symfony, Laravel)
    • Check for PHPUnit
  2. Select sets:

    • PHP version upgrade sets
    • Framework migration sets
    • Code quality sets
  3. Configure skips:

    • Legacy directories
    • Generated code
    • Migrations
  4. Generate config:

    • Create rector.php
    • Add appropriate sets
    • Configure skips

Usage

Provide:

  • Current PHP version
  • Target PHP version
  • Frameworks used
  • Directories to process
  • Directories to skip

The generator will:

  1. Create rector.php configuration
  2. Include appropriate version sets
  3. Include framework sets
  4. Configure quality improvements
  5. Set up proper skips

Current listing version

0.0.1

Verify the source revision ↗

Quality assessment

Out of 100 · Assessment report from SkillPi LAB.

Scenario Value90/100

Highlights

  • 直接解决 PHP 项目中自动化重构配置生成的核心痛点
  • 提供多种预设场景(PHP版本升级、代码质量、框架迁移等),显著提升开发效率
  • 覆盖主流框架(Symfony、Doctrine、PHPUnit)和常见项目结构
Trigger Precision90/100

Highlights

  • 触发词精准完整,覆盖多种变体,边界清晰
  • description 明确描述了 Skill 的核心功能和使用场景
Structure and Standards90/100

Highlights

  • Phase/步骤清晰,有出口条件,含端到端示例
  • frontmatter完整,单文件≤500行
  • 文档结构清晰,包含多个使用场景和配置示例
Execution Reliability90/100

Highlights

  • 工具来源明确,参数正确,覆盖主要异常
  • 提供了详细的配置示例和 CI 集成方案
  • 包含 skip 配置和规则定制,确保执行可靠性
Evidence Verifiability (mean of the first four)90/100

The arithmetic mean of the first four original scores, rounded to a whole number.

Static text checks

100 / 100 · skillpi-20261123-no-r3-v1

No current rules matched the text.

This score reflects rule matches in the text and is provided for reference before use. It excludes attachments and runtime behavior.

Permissions and checks before use

Automatically summarized from this main document. Matches may be examples or defensive advice; they are not actual permission declarations. Attachments, external dependencies and runtime behavior are not covered.

These common operations were not identified in the main document. This does not mean no permissions or risks exist.

These notices grant no permissions. Your host tool must still confirm file changes, secrets, external transfers or costs as needed.

Security rating and access scope

safe · Static evidence review; not a runtime safety guarantee.

Before use, confirm and authorize actual file access, external services and network destinations in your host. This review grants no runtime permissions.