# Rector - Reconstruct your Legacy Code to Modern Codebase [![Build Status](https://img.shields.io/travis/RectorPHP/Rector/master.svg?style=flat-square)](https://travis-ci.org/RectorPHP/Rector) [![Coverage Status](https://img.shields.io/coveralls/RectorPHP/Rector/master.svg?style=flat-square)](https://coveralls.io/github/RectorPHP/Rector?branch=master) This tool will **upgrade your application** for you. ## All Reconstructors At the moment these packages are supported: - [Nette](/src/config/level/nette) - [PHP_CodeSniffer](/src/config/level/php-code-sniffer) - [PHPUnit](/src/config/level/phpunit) - [Roave](/src/config/level/roave) - [Symfony](/src/config/level/symfony) ## Install ```bash composer require rector/rector --dev ``` # Install on PHP < 7.1 You must have separated environment with PHP 7.1 (for example in Docker container). When you have it then run following command. ``` composer create-project rector/rector your-path-to-rector ``` When do you have it then you can run all commands like ``` your-path-to-rector/bin/rector process /var/www/old-project --level=nette24 your-path-to-rector/bin/rector process /var/www/another-old-project --level=symfony40 ``` ## How To Reconstruct your Code? 1. Create `rector.yml` with desired Rectors ```yml rectors: - Rector\Rector\Contrib\Nette\Application\InjectPropertyRector ``` 2. Run rector on your `/src` directory ```bash vendor/bin/rector process src ``` 3. Check the Git ``` git diff ``` ### 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\;` namespace ```php