PHPackages                             carlos-granados/rector - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Database &amp; ORM](/categories/database)
4. /
5. carlos-granados/rector

ActiveLibrary[Database &amp; ORM](/categories/database)

carlos-granados/rector
======================

Instant Upgrade and Automated Refactoring of any PHP code (With extra features)

1.2.9(1y ago)13MITPHPPHP ^7.2|^8.0

Since Oct 4Pushed 1y agoCompare

[ Source](https://github.com/carlos-granados/rector)[ Packagist](https://packagist.org/packages/carlos-granados/rector)[ GitHub Sponsors](https://github.com/tomasvotruba)[ RSS](/packages/carlos-granados-rector/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (2)Dependencies (1)Versions (4)Used By (0)

Additional capabilities
-----------------------

[](#additional-capabilities)

This is a fork of the Rector project which offers several new capabilities:

### Ignore rector rules for particular lines in a file

[](#ignore-rector-rules-for-particular-lines-in-a-file)

You can now use some annotations in comments to ignore a rector rule at a particular point in any file, without having to ignore it for the whole file.

- `@rector-ignore-next-line` will let you skip any rector rule that might be applied to the node defined in the next line
- `@rector-ignore RULE_NAME` will let you skip any particular rector rule that might be applied to the node defined in the next line. `RULE_NAME` needs to be the name of the class for that particular rule (for example `NumericReturnTypeFromStrictScalarReturnsRector`) and you need to add the corresponding use statement (or provide the FQN name of the rule). If you want to skip more than one rule you can list them separated with commas

### Process dependent files

[](#process-dependent-files)

When using the cache, we also process dependent files of modified files to make sure we have covered all possible needed changes.

### Add option to insert use imports in sorted order

[](#add-option-to-insert-use-imports-in-sorted-order)

Add a new `importInsertSorted` parameter to the `withImportNames()` config function.

When this option is set to true, any new use import statements will be inserted in sorted order, including sorting within already existing use statements.

Takes into account the different possible use statement types (normal, function and const). Also works for use groups, including mixed use groups.

This assumes that the existing use statements are already sorted. If that is not the case, the new use statements will be sorted but it is not guaranteed that they will be sorted within the existing use statements as we do not re-order those.

Rector - Instant Upgrades and Automated Refactoring
===================================================

[](#rector---instant-upgrades-and-automated-refactoring)

[![Downloads](https://camo.githubusercontent.com/4dae4724af89e8ef23acd9bba790fbf18d2ae11f2c82c8ee0191ee94b8d5ba79/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f726563746f722f726563746f722e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/rector/rector)

Rector instantly upgrades and refactors the PHP code of your application. It can help you in 2 major areas:

### 1. Instant Upgrades

[](#1-instant-upgrades)

Rector now supports upgrades from PHP 5.3 to 8.2 and major open-source projects like [Symfony](https://github.com/rectorphp/rector-symfony), [PHPUnit](https://github.com/rectorphp/rector-phpunit), and [Doctrine](https://github.com/rectorphp/rector-doctrine). Do you want to **be constantly on the latest PHP and Framework without effort**?

Use Rector to handle **instant upgrades** for you.

### 2. Automated Refactoring

[](#2-automated-refactoring)

Do you have code quality you need, but struggle to keep it with new developers in your team? Do you want to see smart code-reviews even when every senior developers sleeps?

Add Rector to your CI and let it **continuously refactor your code** and keep the code quality high.

Read our [blogpost](https://getrector.com/blog/new-setup-ci-command-to-let-rector-work-for-you) to see how to set up automated refactoring.

Install
-------

[](#install)

```
composer require rector/rector --dev
```

Running Rector
--------------

[](#running-rector)

There are 2 main ways to use Rector:

- a *single rule*, to have the change under control
- or group of rules called *sets*

To use them, create a `rector.php` in your root directory:

```
vendor/bin/rector
```

And modify it:

```
use Rector\Config\RectorConfig;
use Rector\TypeDeclaration\Rector\Property\TypedPropertyFromStrictConstructorRector;

return RectorConfig::configure()
    // register single rule
    ->withRules([
        TypedPropertyFromStrictConstructorRector::class
    ])
    // here we can define, what prepared sets of rules will be applied
    ->withPreparedSets(
        deadCode: true,
        codeQuality: true
    );
```

Then dry run Rector:

```
vendor/bin/rector process src --dry-run
```

Rector will show you diff of files that it *would* change. To *make* the changes, drop `--dry-run`:

```
vendor/bin/rector process src
```

Documentation
-------------

[](#documentation)

- Find [full documentation here](https://getrector.com/documentation/).
- [Explore Rector Rules](https://getrector.com/find-rule)

Learn Faster with a Book
------------------------

[](#learn-faster-with-a-book)

Are you curious, how Rector works internally, how to create your own rules and test them and why Rector was born? Read [Rector - The Power of Automated Refactoring](https://leanpub.com/rector-the-power-of-automated-refactoring) that will take you step by step through the Rector setup and how to create your own rules.

Empowered by Community ❤️
-------------------------

[](#empowered-by-community-heart)

The Rector community is powerful thanks to active maintainers who take care of Rector sets for particular projects.

Among there projects belong:

- [palantirnet/drupal-rector](https://github.com/palantirnet/drupal-rector)
- [craftcms/rector](https://github.com/craftcms/rector)
- [FriendsOfShopware/shopware-rector](https://github.com/FriendsOfShopware/shopware-rector)
- [sabbelasichon/typo3-rector](https://github.com/sabbelasichon/typo3-rector)
- [sulu/sulu-rector](https://github.com/sulu/sulu-rector)
- [efabrica-team/rector-nette](https://github.com/efabrica-team/rector-nette)
- [Sylius/SyliusRector](https://github.com/Sylius/SyliusRector)
- [CoditoNet/rector-money](https://github.com/CoditoNet/rector-money)
- [laminas/laminas-servicemanager-migration](https://github.com/laminas/laminas-servicemanager-migration)
- [cakephp/upgrade](https://github.com/cakephp/upgrade)
- [driftingly/rector-laravel](https://github.com/driftingly/rector-laravel)
- [contao/contao-rector](https://github.com/contao/contao-rector)
- [php-static-analysis/rector-rule](https://github.com/php-static-analysis/rector-rule)

Hire us to get Job Done 💪
-------------------------

[](#hire-us-to-get-job-done-muscle)

Rector is a tool that [we develop](https://getrector.com/) and share for free, so anyone can automate their refactoring. But not everyone has dozens of hours to understand complexity of abstract-syntax-tree in their own time. **That's why we provide commercial support - to save your time**.

Would you like to apply Rector on your code base but don't have time for the struggle with your project? [Hire us](https://getrector.com/contact) to get there faster.

How to Contribute
-----------------

[](#how-to-contribute)

See [the contribution guide](/CONTRIBUTING.md) or go to development repository [rector/rector-src](https://github.com/rectorphp/rector-src).

Debugging
---------

[](#debugging)

You can use `--debug` option, that will print nested exceptions output:

```
vendor/bin/rector process src/Controller --dry-run --debug
```

Or with Xdebug:

1. Make sure [Xdebug](https://xdebug.org/) is installed and configured
2. Add `--xdebug` option when running Rector

```
vendor/bin/rector process src/Controller --dry-run --xdebug
```

To assist with simple debugging Rector provides 2 helpers to pretty-print AST-nodes:

```
use PhpParser\Node\Scalar\String_;
$node = new String_('hello world!');

// prints node to string, as PHP code displays it
print_node($node);
```

Known Drawbacks
---------------

[](#known-drawbacks)

- Rector uses [nikic/php-parser](https://github.com/nikic/PHP-Parser/), built on technology called an *abstract syntax tree* (AST). An AST doesn't know about spaces and when written to a file it produces poorly formatted code in both PHP and docblock annotations.
- Rector in parallel mode will work most of the times for most OS. On Windows, you may encounter issues unresolvable despite of following the [Troubleshooting Parallel](https://getrector.com/documentation/troubleshooting-parallel) guide. In such case, check if you are using Powershell 7 (pwsh). Change your terminal to command prompt (cmd) or bash for Windows.

### How to Apply Coding Standards?

[](#how-to-apply-coding-standards)

**Your project needs to have a coding standard tool** and a set of formatting rules, so it can make Rector's output code nice and shiny again.

We're using [ECS](https://github.com/symplify/easy-coding-standard) with [this setup](https://github.com/rectorphp/rector-src/blob/main/ecs.php).

### May cause unexpected output on File with mixed PHP+HTML content

[](#may-cause-unexpected-output-on-file-with-mixed-phphtml-content)

When you apply changes to File(s) thas has mixed PHP+HTML content, you may need to manually verify the changed file after apply the changes.

###  Health Score

28

—

LowBetter than 54% of packages

Maintenance38

Infrequent updates — may be unmaintained

Popularity5

Limited adoption so far

Community19

Small or concentrated contributor base

Maturity46

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 90.7% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~33 days

Total

2

Last Release

551d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/c2636f870530771eeacdaa267730b05040bf6f96fd7ebe0d51696be25b2d7bba?d=identicon)[barelon](/maintainers/barelon)

---

Top Contributors

[![TomasVotruba](https://avatars.githubusercontent.com/u/924196?v=4)](https://github.com/TomasVotruba "TomasVotruba (16055 commits)")[![samsonasik](https://avatars.githubusercontent.com/u/459648?v=4)](https://github.com/samsonasik "samsonasik (419 commits)")[![carusogabriel](https://avatars.githubusercontent.com/u/16328050?v=4)](https://github.com/carusogabriel "carusogabriel (279 commits)")[![kodiakhq[bot]](https://avatars.githubusercontent.com/in/29196?v=4)](https://github.com/kodiakhq[bot] "kodiakhq[bot] (157 commits)")[![gnutix](https://avatars.githubusercontent.com/u/310134?v=4)](https://github.com/gnutix "gnutix (84 commits)")[![JanMikes](https://avatars.githubusercontent.com/u/3995003?v=4)](https://github.com/JanMikes "JanMikes (79 commits)")[![jeroensmit](https://avatars.githubusercontent.com/u/1814884?v=4)](https://github.com/jeroensmit "jeroensmit (72 commits)")[![dobryy](https://avatars.githubusercontent.com/u/679007?v=4)](https://github.com/dobryy "dobryy (61 commits)")[![mssimi](https://avatars.githubusercontent.com/u/16163762?v=4)](https://github.com/mssimi "mssimi (57 commits)")[![staabm](https://avatars.githubusercontent.com/u/120441?v=4)](https://github.com/staabm "staabm (57 commits)")[![github-actions[bot]](https://avatars.githubusercontent.com/in/15368?v=4)](https://github.com/github-actions[bot] "github-actions[bot] (54 commits)")[![Aerendir](https://avatars.githubusercontent.com/u/1968622?v=4)](https://github.com/Aerendir "Aerendir (45 commits)")[![leoloso](https://avatars.githubusercontent.com/u/1981996?v=4)](https://github.com/leoloso "leoloso (45 commits)")[![markstory](https://avatars.githubusercontent.com/u/24086?v=4)](https://github.com/markstory "markstory (19 commits)")[![keulinho](https://avatars.githubusercontent.com/u/15930605?v=4)](https://github.com/keulinho "keulinho (19 commits)")[![simivar](https://avatars.githubusercontent.com/u/828020?v=4)](https://github.com/simivar "simivar (19 commits)")[![lulco](https://avatars.githubusercontent.com/u/9377319?v=4)](https://github.com/lulco "lulco (18 commits)")[![ruudk](https://avatars.githubusercontent.com/u/104180?v=4)](https://github.com/ruudk "ruudk (17 commits)")[![shyim](https://avatars.githubusercontent.com/u/6224096?v=4)](https://github.com/shyim "shyim (14 commits)")[![greg0ire](https://avatars.githubusercontent.com/u/657779?v=4)](https://github.com/greg0ire "greg0ire (14 commits)")

---

Tags

devautomationmigrationrefactoring

### Embed Badge

![Health badge](/badges/carlos-granados-rector/health.svg)

```
[![Health](https://phpackages.com/badges/carlos-granados-rector/health.svg)](https://phpackages.com/packages/carlos-granados-rector)
```

###  Alternatives

[rector/rector

Instant Upgrade and Automated Refactoring of any PHP code

10.3k123.1M6.0k](/packages/rector-rector)[ssch/typo3-rector

Instant fixes for your TYPO3 PHP code by using Rector.

2592.8M263](/packages/ssch-typo3-rector)[rector/rector-src

Instant Upgrade and Automated Refactoring of any PHP code

134391.5k12](/packages/rector-rector-src)[a9f/typo3-fractor

TYPO3 extension for the File Read-Analyse-Change Tool. Allows modifying XML files

17213.8k36](/packages/a9f-typo3-fractor)[doctrine/coding-standard

The Doctrine Coding Standard is a set of PHPCS rules applied to all Doctrine projects.

31914.1M739](/packages/doctrine-coding-standard)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
