Instant Upgrades and Automated Refactoring of any PHP 5.3+ code
Go to file
2017-08-24 12:00:16 +02:00
bin cs fixes, drop duplicated NodeVisitor 2017-08-12 13:34:40 +02:00
packages/NodeTypeResolver [NodeTypeResolver] add method argument type 2017-08-21 12:04:35 +02:00
src [Rector] PhpGeneratorDocument init 2017-08-24 12:00:04 +02:00
tests [Rector] PhpGeneratorDocument tests init 2017-08-24 12:00:16 +02:00
.coveralls.yml init meta files 2017-07-15 19:12:04 +02:00
.gitignore init 2017-07-15 19:01:21 +02:00
.travis.yml simplify travis.yml 2017-08-15 15:19:34 +02:00
CODE_OF_CONDUCT.md init meta files 2017-07-15 19:12:04 +02:00
composer.json add /packages directory to static analysis check 2017-08-20 17:20:33 +02:00
easy-coding-standard.neon [Rector] FormCallbackRector - use type 2017-08-21 12:37:43 +02:00
LICENSE init meta files 2017-07-15 19:12:04 +02:00
phpstan.neon phpstan fixes 2017-08-10 12:29:43 +02:00
phpunit.xml add /packages directory to static analysis check 2017-08-20 17:20:33 +02:00
README.md [README] bit info added 2017-08-21 12:12:51 +02:00

Rector - Reconstruct your Legacy Code to Modern Codebase

Build Status Coverage Status

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
{
}
  1. 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
{
    // ...
}
  1. Add a Test Case

  2. Submit PR

  3. :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.