eliashaeussler/rector-config

Rector 的个人配置

3.0.2 2024-07-06 16:34 UTC

This package is auto-updated.

Last update: 2024-09-22 03:17:51 UTC


README

Rector 配置

Coverage Maintainability CGL Tests Supported PHP Versions

此包包含用于个人项目的 Rector 基本配置。它不打算用于其他地方。我不会为此仓库提供支持,也不接受 pull request。

🔥 安装

Packagist Packagist Downloads

composer require --dev eliashaeussler/rector-config

⚡ 使用

# rector.php

use EliasHaeussler\RectorConfig\Config\Config;
use EliasHaeussler\RectorConfig\Set\CustomSet;
use Rector\Config\RectorConfig;
use Rector\Php80\Rector\Class_\AnnotationToAttributeRector;
use Rector\Set\ValueObject\SetList;
use Rector\ValueObject\PhpVersion;

return static function (RectorConfig $rectorConfig): void {
    // Optional: Configure PHP version explicitly
    // Can be left out to use the current environment's PHP version
    $phpVersion = PhpVersion::PHP_81;

    // Create config from Rector config object
    $config = Config::create($rectorConfig, $phpVersion)->in(
        __DIR__.'/src',
        __DIR__.'/tests',
    );

    // Skip specific paths
    $config->not(
        __DIR__.'/src/lib',
        __DIR__.'/tests/test-application/vendor',
    );

    // Include default PHPUnit sets
    $config->withPHPUnit();

    // Include default Symfony sets
    $config->withSymfony();

    // Include default TYPO3 sets
    $config->withTYPO3();

    // Include custom sets
    $config->withSets(
        new CustomSet(
            SetList::CODE_QUALITY,
            SetList::CODING_STYLE,
        ),
    );

    // Skip specific rectors
    $config->skip(
        AnnotationToAttributeRector::class,
        [
            __DIR__.'/src/Some/File.php',
        ],
    );

    // Apply configuration
    $config->apply();
};

⭐ 许可证

此项目受 GNU 通用公共许可证 3.0(或更新版) 许可。