PHPackages                             guanguans/rector-rules - 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. [Testing &amp; Quality](/categories/testing)
4. /
5. guanguans/rector-rules

ActiveLibrary[Testing &amp; Quality](/categories/testing)

guanguans/rector-rules
======================

A set of additional rules for rector/rector. - 一套针对 `rector/rector` 的附加规则。

1.7.1(1mo ago)12.3k10MITPHPPHP &gt;=7.4CI passing

Since Jan 3Pushed 1mo agoCompare

[ Source](https://github.com/guanguans/rector-rules)[ Packagist](https://packagist.org/packages/guanguans/rector-rules)[ Docs](https://github.com/guanguans/rector-rules)[ Fund](https://guanguans.github.io/sponsors)[ RSS](/packages/guanguans-rector-rules/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (10)Dependencies (99)Versions (19)Used By (10)

rector-rules
============

[](#rector-rules)

Note

A set of additional rules for rector/rector. - 一套针对 `rector/rector` 的附加规则。

[![tests](https://github.com/guanguans/rector-rules/actions/workflows/tests.yml/badge.svg)](https://github.com/guanguans/rector-rules/actions/workflows/tests.yml)[![php-cs-fixer](https://github.com/guanguans/rector-rules/actions/workflows/php-cs-fixer.yml/badge.svg)](https://github.com/guanguans/rector-rules/actions/workflows/php-cs-fixer.yml)[![codecov](https://camo.githubusercontent.com/94c66fa35b4df241118ff49b1c28836e59b373d7388f7cf75b486bb4180f1207/68747470733a2f2f636f6465636f762e696f2f67682f6775616e6775616e732f726563746f722d72756c65732f67726170682f62616467652e7376673f746f6b656e3d3052746753476f6d344b)](https://codecov.io/gh/guanguans/rector-rules)[![Latest Stable Version](https://camo.githubusercontent.com/46dec6fc90dc2012d54486d3f1386276f10d472482a6b9707af5e408e5ed4d7a/68747470733a2f2f706f7365722e707567782e6f72672f6775616e6775616e732f726563746f722d72756c65732f76)](https://packagist.org/packages/guanguans/rector-rules)[![GitHub release (with filter)](https://camo.githubusercontent.com/8e1fb3ea0aee81c288f9040bfd699a96456d59181c1e664fbc6b7f2370f0ebd3/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f762f72656c656173652f6775616e6775616e732f726563746f722d72756c6573)](https://github.com/guanguans/rector-rules/releases)[![Total Downloads](https://camo.githubusercontent.com/d35e827112843e5252b02d4d37c2bc06217cd113da8ae3c4750512f99f1fbe8c/68747470733a2f2f706f7365722e707567782e6f72672f6775616e6775616e732f726563746f722d72756c65732f646f776e6c6f616473)](https://packagist.org/packages/guanguans/rector-rules)[![License](https://camo.githubusercontent.com/6f327e20990875fa18255cbe3442e8cedfa15251764499ef4090be63034c8c33/68747470733a2f2f706f7365722e707567782e6f72672f6775616e6775616e732f726563746f722d72756c65732f6c6963656e7365)](https://packagist.org/packages/guanguans/rector-rules)

Requirement
-----------

[](#requirement)

- PHP &gt;= 7.4

Installation
------------

[](#installation)

```
composer require guanguans/rector-rules --dev --ansi -v
```

Usage
-----

[](#usage)

### 🧐 [Rules Overview](docs/rules-overview.md)

[](#monocle_face-rules-overview)

### 🧐 [Sets Overview](config/set/)

[](#monocle_face-sets-overview)

- [`Guanguans\RectorRules\Set\SetList::ALL`](src/Set/SetList.php)
- [`Guanguans\RectorRules\Set\SetList::COMMON`](src/Set/SetList.php)
- [`Guanguans\RectorRules\Set\SetList::GUZZLE`](src/Set/SetList.php)
- [`Guanguans\RectorRules\Set\SetList::LARAVEL`](src/Set/SetList.php)
- [`Guanguans\RectorRules\Set\SetList::PEST`](src/Set/SetList.php)
- [`Guanguans\RectorRules\Set\SetList::PHPBENCH`](src/Set/SetList.php)
- [`Guanguans\RectorRules\Set\SetList::PHPSTAN`](src/Set/SetList.php)
- [`Guanguans\RectorRules\Set\SetList::RECTOR`](src/Set/SetList.php)
- [`Guanguans\RectorRules\Set\SetList::SYMFONY`](src/Set/SetList.php)

### In your rector configuration register rules

[](#in-your-rector-configuration-register-rules)

```
use Guanguans\RectorRules\Rector\File\SortFileFunctionStmtRector;
use Guanguans\RectorRules\Rector\FunctionLike\RenameGarbageParamNameRector;
use Guanguans\RectorRules\Rector\Name\RenameToConventionalCaseNameRector;
use PhpParser\NodeVisitor\ParentConnectingVisitor;
use Rector\Config\RectorConfig;

return RectorConfig::configure()
    ->withSets([
        Guanguans\RectorRules\Set\SetList::ALL,
        // ...
    ])
    // ...
    ->registerDecoratingNodeVisitor(ParentConnectingVisitor::class)
    ->withConfiguredRule(RenameToConventionalCaseNameRector::class, [
        'assertMatches*Snapshot', // Exclude `spatie/pest-plugin-snapshots` function name
        'beforeEach', // Exclude `pestphp/pest` function name
        'PDO', // Exclude `ext-pdo` class name
    ])
    // ...
    ->withRules([
        RenameGarbageParamNameRector::class,
        SortFileFunctionStmtRector::class,
        // ...
    ]);
```

### Example of RenameToConventionalCaseNameRector

[](#example-of-renametoconventionalcasenamerector)

```
 /** @noinspection ALL */
 // @formatter:off
 // phpcs:ignoreFile

 // lower snake
-use function functionName;
-function functionName(){}
-functionName();
-call_user_func('functionName');
-call_user_func_array('functionName', []);
-function_exists('functionName');
+use function function_name;
+function function_name(){}
+\function_name();
+call_user_func('function_name');
+call_user_func_array('function_name', []);
+function_exists('function_name');

 // ucfirst camel
 // #[attribute_name()]
-class class_name{}
+class ClassName{}
 // enum enum_name{}
 // enum Enum{case case_name;}
-interface interface_name{}
-trait trait_name{}
-class Foo extends class_name implements interface_name{}
-class_name::$property;
-class_name::CONST;
-class_name::method();
+interface InterfaceName{}
+trait TraitName{}
+class Foo extends \ClassName implements \InterfaceName{}
+\ClassName::$property;
+\ClassName::CONST;
+\ClassName::method();
 // enum Enum implements interface_name{}
-use class_name;
-use trait_name;
-class_alias('class_name', 'alias_class_name');
-class_alias($className, 'alias_class_name');
-class_exists('class_name');
-class_implements('class_name');
-class_parents('class_name');
-class_uses('class_name');
-enum_exists('enum_name');
-get_class_methods('class_name');
-get_class_vars('class_name');
-get_parent_class('class_name');
-interface_exists('interface_name');
-is_subclass_of('class_name', 'parent_class_name');
-is_subclass_of($className, 'parent_class_name');
-trait_exists('trait_name', true);
+use ClassName;
+use TraitName;
+class_alias('ClassName', 'AliasClassName');
+class_alias($className, 'AliasClassName');
+class_exists('ClassName');
+class_implements('ClassName');
+class_parents('ClassName');
+class_uses('ClassName');
+enum_exists('EnumName');
+get_class_methods('ClassName');
+get_class_vars('ClassName');
+get_parent_class('ClassName');
+interface_exists('InterfaceName');
+is_subclass_of('ClassName', 'ParentClassName');
+is_subclass_of($className, 'ParentClassName');
+trait_exists('TraitName', true);

 // upper snake
-use const constName;
-class Foo{public const constName = 'const';}
-Foo::constName;
-define('constName', 'const');
-defined('constName');
-constant('constName');
-constant('Foo::constName');
-constName;
+use const CONST_NAME;
+class Foo{public const CONST_NAME = 'const';}
+Foo::CONST_NAME;
+define('CONST_NAME', 'const');
+defined('CONST_NAME');
+constant('CONST_NAME');
+constant('Foo::CONST_NAME');
+\CONST_NAME;

 // lcfirst camel
-$var_name;
-$object->method_name();
-$object->property_name;
-call_user_method('method_name', $object);
-call_user_method_array('method_name', $object);
-class Foo{public $property_name;}
-class Foo{public function method_name(){}}
-class Foo{public int $property_name;}
-Foo::$property_name;
-Foo::method_name();
-method_exists($object, 'method_name');
-property_exists($object, 'property_name');
+$varName;
+$object->methodName();
+$object->propertyName;
+call_user_method('methodName', $object);
+call_user_method_array('methodName', $object);
+class Foo{public $propertyName;}
+class Foo{public function methodName(){}}
+class Foo{public int $propertyName;}
+Foo::$propertyName;
+Foo::methodName();
+method_exists($object, 'methodName');
+property_exists($object, 'propertyName');
```

Composer scripts
----------------

[](#composer-scripts)

```
composer checks:required
composer php-cs-fixer:fix
composer test
```

Changelog
---------

[](#changelog)

Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.

Contributing
------------

[](#contributing)

Please see [CONTRIBUTING](.github/CONTRIBUTING.md) for details.

Security Vulnerabilities
------------------------

[](#security-vulnerabilities)

Please review [our security policy](../../security/policy) on how to report security vulnerabilities.

Credits
-------

[](#credits)

- [guanguans](https://github.com/guanguans)
- [All Contributors](../../contributors)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE) for more information.

###  Health Score

45

—

FairBetter than 93% of packages

Maintenance89

Actively maintained with recent releases

Popularity24

Limited adoption so far

Community17

Small or concentrated contributor base

Maturity43

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 97% 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 ~4 days

Recently: every ~13 days

Total

18

Last Release

54d ago

### Community

Maintainers

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

---

Top Contributors

[![guanguans](https://avatars.githubusercontent.com/u/22309277?v=4)](https://github.com/guanguans "guanguans (97 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (3 commits)")

---

Tags

devformatformatterlintlinterrectorrefactorrulestandardstatic-analysistestingformattertestingdevstatic analysisformatstandardlinterlintrulerefactorrector

###  Code Quality

TestsPest

Static AnalysisPHPStan

Type Coverage Yes

### Embed Badge

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

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

###  Alternatives

[laravel/pint

An opinionated code formatter for PHP.

3.1k147.7M13.2k](/packages/laravel-pint)[ssch/typo3-rector

Instant fixes for your TYPO3 PHP code by using Rector.

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

Rector upgrade rules for Pest - refactoring and best practices for Pest testing framework

4717.6k18](/packages/mrpunyapal-rector-pest)[dragon-code/codestyler

A tool to automatically fix Coding Style Standards issues by The Dragon Code.

291.8M16](/packages/dragon-code-codestyler)[guanguans/laravel-soar

SQL optimizer and rewriter for laravel. - laravel 的 SQL 优化器和重写器。

2227.8k](/packages/guanguans-laravel-soar)[savinmikhail/add_named_arguments_rector

Rector rule to add names to arguments for functions'/methods' calls

1969.5k3](/packages/savinmikhail-add-named-arguments-rector)

PHPackages © 2026

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