rector/README.md
2017-09-09 20:44:44 +02:00

91 lines
1.8 KiB
Markdown

# Rector - Reconstruct your Legacy Code to Modern Codebase
[![Build Status](https://img.shields.io/travis/TomasVotruba/Rector/master.svg?style=flat-square)](https://travis-ci.org/TomasVotruba/Rector)
[![Coverage Status](https://img.shields.io/coveralls/TomasVotruba/Rector/master.svg?style=flat-square)](https://coveralls.io/github/TomasVotruba/Rector?branch=master)
This tool will **upgrade your application** for you.
## All Reconstructors
At the moment these packages are supported:
- [Nette](/src/Rector/Contrib/Nette)
- [Symfony](/src/Rector/Contrib/Symfony)
- [PHPUnit](/src/Rector/Contrib/PHPUnit)
- [PHP_CodeSniffer](/src/Rector/Contrib/PHP_CodeSniffer)
## Install
```bash
composer require rector/rector --dev
```
## Use (WIP)
```bash
vendor/bin/rector reconstruct src --level=nette24
vendor/bin/rector reconstruct src --level=symfony40
```
### 6 Steps to Add New Rector
Just extend `Rector\Rector\AbstractRector`.
It will prepare **2 methods** processing the node.
```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
{
// ...
}
```
3. Add a Test Case
4. Add to specific level, e.g. [`/src/config/level/nette/nette24.yml`](/src/config/level/nette/nette24.yml)
5. Submit PR
6. :check:
### How to Contribute
Just follow 3 rules:
- **1 feature per pull-request**
- **New feature needs tests**
- Tests, coding standard and PHPStan **checks must pass**
```bash
composer all
```
Don you need to fix coding standards? Run:
```bash
composer fix-cs
```
We would be happy to merge your feature then.