rector-rules - 提供标准化的常量、变量、函数、类、属性和方法命名以及其他 Rector 规则
rector-rules - 提供标准化的常量、变量、函数、类、属性和方法命名以及其他 Rector 规则
之前写过用 Rector 《统一规范化代码的命名风格》,现在已经整理发布为 Composer 包了。
rector-rules - 提供标准化的常量、变量、函数、类、属性和方法命名以及其他 Rector 规则。
Rector 规则总览
Rector 规则集总览
Guanguans\RectorRules\Set\SetList::ALLGuanguans\RectorRules\Set\SetList::COMMONGuanguans\RectorRules\Set\SetList::PHPBENCHGuanguans\RectorRules\Set\SetList::PHPSTANGuanguans\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,
// ...
]);
另外推荐下其他相关类似的包
- php-cs-fixer-custom-fixers - 用 php-cs-fixer 统一修复项目中的非 php 格式文件
- monorepo-builder-worker - 用 monorepo-builder 自动化生成 changelog / 自动化项目发布流程
- phpstan-rules - 一些附加的 phpstan 规则

浙公网安备 33010602011771号