2017-11-18 16:19:47 +01:00
## 6 Steps to Add New Rector
2018-08-03 09:17:19 +02:00
In case you need a transformation that you didn't find in General Rectors, you can create your own:
2017-11-18 16:19:47 +01:00
1. Just extend `Rector\Rector\AbstractRector` class. It will prepare **2 methods** :
```php
public function isCandidate(Node $node): bool
{
}
public function refactor(Node $node): ?Node
{
}
```
2. Put it under `namespace Rector\Contrib\<set>;` namespace
```php
< ?php declare(strict_types=1);
namespace Rector\Contrib\Symfony;
use Rector\Rector\AbstractRector;
final class MyRector extends AbstractRector
{
// ...
}
```
2017-11-21 05:08:49 +01:00
3. Add a Test Case - [see PHPUnit example ](https://github.com/rectorphp/rector/blob/master/tests/Rector/Contrib/PHPUnit/ExceptionAnnotationRector/Test.php )
2017-11-18 16:19:47 +01:00
4. Add to specific level, e.g. [`/src/config/level/symfony/symfony33.yml` ](/src/config/level/symfony/symfony33.yml )
5. Submit PR
6. :+1: