欢迎光临
我们一直在努力

rector-rules – 提供标准化的常量、变量、函数、类、属性和方法命名以及其他 Rector 规则

rector-rules – 提供标准化的常量、变量、函数、类、属性和方法命名以及其他 Rector 规则

之前写过用 Rector 《统一规范化代码的命名风格》,现在已经整理发布为 Composer 包了。

rector-rules – 提供标准化的常量、变量、函数、类、属性和方法命名以及其他 Rector 规则。

Rector 规则总览

Rector 规则集总览

  • Guanguans/RectorRules/Set/SetList::ALL
  • Guanguans/RectorRules/Set/SetList::COMMON
  • Guanguans/RectorRules/Set/SetList::PHPBENCH
  • Guanguans/RectorRules/Set/SetList::PHPSTAN
  • Guanguans/RectorRules/Set/SetList::RECTOR

配置使用规则集和规则

use Guanguans/RectorRules/Rector/File/SortFileFunctionStmtRector;
use Guanguans/RectorRules/Rector/Name/RenameToPsrNameRector;
use PhpParser/NodeVisitor/ParentConnectingVisitor;
use Rector/Config/RectorConfig;

return RectorConfig::configure()
    ->withSets([
        Guanguans/RectorRules/Set/SetList::ALL,
        // ...
    ])
    // ...
    ->registerDecoratingNodeVisitor(ParentConnectingVisitor::class)
    ->withConfiguredRule(RenameToPsrNameRector::class, [
        'assertMatches*Snapshot', // 排除 spatie/pest-plugin-snapshots 包的函数名称
        'beforeEach', // 排除 pestphp/pest 包的函数名称
        'PDO', // 排除 PDO 类名称
    ])
    // ...
    ->withRules([
        SortFileFunctionStmtRector::class,
        // ...
    ]);

另外推荐下其他相关类似的包

https://segmentfault.com/a/1190000047553406

未经允许不得转载:IT极限技术分享汇 » rector-rules – 提供标准化的常量、变量、函数、类、属性和方法命名以及其他 Rector 规则

评论 抢沙发

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址