remarkablemark/rector-template

dev-master 2024-09-09 13:49 UTC

This package is auto-updated.

Last update: 2024-09-09 13:49:20 UTC


README

packagist test

Rector 模板。来自 Rector 自定义规则 的示例。

需求

PHP >=7.2

安装

使用 Composer 安装

composer require --dev rector/rector remarkablemark/rector-template

使用方法

rector.php 中注册规则

<?php

declare(strict_types=1);

use Rector\Config\RectorConfig;
use Remarkablemark\RectorTemplate\ExampleRector;

return static function (RectorConfig $rectorConfig): void {
    $rectorConfig->paths([
        __DIR__,
    ]);
    $rectorConfig->rule(ExampleRector::class);
};

查看差异

vendor/bin/rector process --dry-run

应用规则

vendor/bin/rector process

清除缓存并应用规则

vendor/bin/rector process --clear-cache

规则

之前

$user->setPassword('123456');

之后

$user->changePassword('123456');

许可

MIT