mirror of
https://github.com/rectorphp/rector.git
synced 2024-09-06 15:41:59 +00:00
Instant Upgrades and Automated Refactoring of any PHP 5.3+ code
|
||
---|---|---|
bin | ||
packages/NodeTypeResolver | ||
src | ||
tests | ||
.coveralls.yml | ||
.gitignore | ||
.travis.yml | ||
CODE_OF_CONDUCT.md | ||
composer.json | ||
easy-coding-standard.neon | ||
LICENSE | ||
phpstan.neon | ||
phpunit.xml | ||
README.md |
Rector - Reconstruct your Legacy Code to Modern Codebase
This tool will reconstruct (change) your code - run it only in a new clean git branch.
All Reconstructors
Nette
FormCallbackRector
InjectPropertyRector
HtmlAddMethodRector
NetteObjectToSmartTraitRector
RemoveConfiguratorConstantsRector
Symfony
NamedServicesToConstructorNodeTraverser
Abstract to use
AbstractChangeMethodNameRector
Install
composer require rector/rector --dev
Use (WIP)
vendor/bin/rector reconstruct src --framework Nette --to-version 2.4
vendor/bin/rector reconstruct src --framework Symfony --to-version 3.3
How to Add New Rector
Just extend Rector\Rector\AbstractRector
.
It will prepare 4 methods - 2 informative and 2 processing the node.
/**
* A project that is related to this.
* E.g "Nette", "Symfony"
* Use constants from @see SetNames, if possible.
*/
public function getSetName(): string
{
}
/**
* Version this deprecations is active since.
* E.g. 2.3.
*/
public function sinceVersion(): float
{
}
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
-
Submit PR
-
: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
composer all
Don you need to fix coding standards? Run:
composer fix-cs
We would be happy to merge your feature then.