mirror of
https://github.com/rectorphp/rector.git
synced 2025-01-19 06:18:07 +01:00
857 B
857 B
6 Steps to Add New Rector
In case you need a transformation that you didn't find in General Rectors, you can create your own:
- Just extend
Rector\Rector\AbstractRector
class. It will prepare 2 methods:
public function isCandidate(Node $node): bool
{
}
public function refactor(Node $node): ?Node
{
}
- Put it under
namespace Rector\Contrib\<set>;
namespace
<?php declare(strict_types=1);
namespace Rector\Contrib\Symfony;
use Rector\Rector\AbstractRector;
final class MyRector extends AbstractRector
{
// ...
}
-
Add a Test Case - see PHPUnit example
-
Add to specific level, e.g.
/src/config/level/symfony/symfony33.yml
-
Submit PR
-
👍