承接 mrpunyapal/rector-pest 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

mrpunyapal/rector-pest

最新稳定版本:0.1.8

Composer 安装命令:

composer require --dev mrpunyapal/rector-pest

包简介

Rector upgrade rules for Pest - refactoring and best practices for Pest testing framework

README 文档

README

Latest Version on Packagist Total Downloads on Packagist CI

Rector rules for PestPHP to improve code quality and help with version upgrades.

Available Rules

See all available Pest rules here.

Installation

composer require --dev mrpunyapal/rector-pest

Available Rule Sets

Code Quality

Improve your Pest tests with better readability and expressiveness.

// rector.php
use RectorPest\Set\PestSetList;
use Rector\Config\RectorConfig;

return RectorConfig::configure()
    ->withPaths([
        __DIR__ . '/tests',
    ])
    ->withSets([
        PestSetList::PEST_CODE_QUALITY,
    ]);
Set Description
PestSetList::PEST_CODE_QUALITY Converts expect() assertions to use Pest's built-in matchers for better readability

Version Upgrade Sets

Use PestLevelSetList to automatically upgrade to a specific Pest version. Sets for higher versions include sets for lower versions.

// rector.php
use RectorPest\Set\PestLevelSetList;
use Rector\Config\RectorConfig;

return RectorConfig::configure()
    ->withPaths([
        __DIR__ . '/tests',
    ])
    ->withSets([
        PestLevelSetList::UP_TO_PEST_40,
    ]);
Set Description
PestLevelSetList::UP_TO_PEST_30 Upgrade from Pest v2 to v3
PestLevelSetList::UP_TO_PEST_40 Upgrade from Pest v2/v3 to v4 (includes v3 changes)

Manual Version Configuration

Use PestSetList if you only want changes for a specific version:

// rector.php
use RectorPest\Set\PestSetList;
use Rector\Config\RectorConfig;

return RectorConfig::configure()
    ->withPaths([
        __DIR__ . '/tests',
    ])
    ->withSets([
        PestSetList::PEST_30, // Only v2→v3 changes
    ]);
Set Description
PestSetList::PEST_30 Pest v2 → v3 migration rules
PestSetList::PEST_40 Pest v3 → v4 migration rules

Using Individual Rules

You can also use individual rules instead of sets:

// rector.php
use RectorPest\Rules\ChainExpectCallsRector;
use Rector\Config\RectorConfig;

return RectorConfig::configure()
    ->withPaths([
        __DIR__ . '/tests',
    ])
    ->withRules([
        ChainExpectCallsRector::class,
    ]);

Running Rector

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

# Apply changes
vendor/bin/rector process

Requirements

  • PHP 8.2+
  • Rector 2.0+

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

License

The MIT License (MIT). Please see License File for more information.

统计信息

  • 总下载量: 2.69k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 34
  • 点击次数: 2
  • 依赖项目数: 3
  • 推荐数: 0

GitHub 信息

  • Stars: 34
  • Watchers: 3
  • Forks: 3
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-12-10