PHPackages                             hungthai1401/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. [Utility &amp; Helpers](/categories/utility)
4. /
5. hungthai1401/rector

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

hungthai1401/rector
===================

Instant Upgrade and Automated Refactoring of any PHP code

0.15.2.1(3y ago)013MITPHPPHP ^7.2|^8.0

Since Nov 4Pushed 3y agoCompare

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

READMEChangelog (1)Dependencies (1)Versions (387)Used By (0)

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.1 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.

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 init
```

And modify it:

```
use Rector\Config\RectorConfig;
use Rector\Set\ValueObject\SetList;
use Rector\TypeDeclaration\Rector\Property\TypedPropertyFromStrictConstructorRector;

return static function (RectorConfig $rectorConfig): void {
    // register single rule
    $rectorConfig->rule(TypedPropertyFromStrictConstructorRector::class);

    // here we can define, what sets of rules will be applied
    // tip: use "SetList" class to autocomplete sets with your IDE
    $rectorConfig->sets([
        SetList::CODE_QUALITY
    ]);
};
```

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.org/documentation/).
- [Explore Rector Rules](/docs/rector_rules_overview.md)

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)

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

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

Rector is a tool that [we develop](https://getrector.org/) 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.org/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
```

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

[](#known-drawbacks)

### How to Apply Coding Standards?

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

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. **That's why 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).

###  Health Score

33

—

LowBetter than 75% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity5

Limited adoption so far

Community19

Small or concentrated contributor base

Maturity78

Established project with proven stability

 Bus Factor1

Top contributor holds 88.6% 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 ~5 days

Recently: every ~12 days

Total

385

Last Release

1228d ago

PHP version history (8 changes)v0.1.0PHP ^7.1

v0.6.0PHP ^7.2

v0.7.3PHP ^7.2.3

v0.7.6PHP ^7.2.4

v0.8.1PHP ^7.2.4|^8.0

0.9.0PHP ^7.3|^8.0

0.11.0PHP ^7.1|^8.0

0.12.20PHP ^7.2|^8.0

### Community

Maintainers

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

---

Top Contributors

[![TomasVotruba](https://avatars.githubusercontent.com/u/924196?v=4)](https://github.com/TomasVotruba "TomasVotruba (12812 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)")

### Embed Badge

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

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

###  Alternatives

[ticketswap/phpstan-error-formatter

A minimalistic error formatter for PHPStan

87578.8k35](/packages/ticketswap-phpstan-error-formatter)[ramsey/devtools

A Composer plugin to aid PHP library and application development.

7134.7k26](/packages/ramsey-devtools)[johnbillion/wp-compat

PHPStan extension to help verify that your PHP code is compatible with a given version of WordPress

24115.0k10](/packages/johnbillion-wp-compat)

PHPackages © 2026

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