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

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

ergebnis/rector-rules
=====================

Provides rules for rector/rector.

1.18.2(1w ago)10245.6k↑164.3%[2 PRs](https://github.com/ergebnis/rector-rules/pulls)20MITPHPPHP ~7.4.0 || ~8.0.0 || ~8.1.0 || ~8.2.0 || ~8.3.0 || ~8.4.0 || ~8.5.0

Since Sep 30Pushed 5d ago3 watchersCompare

[ Source](https://github.com/ergebnis/rector-rules)[ Packagist](https://packagist.org/packages/ergebnis/rector-rules)[ Docs](https://github.com/ergebnis/rector-rules)[ RSS](/packages/ergebnis-rector-rules/feed)WikiDiscussions main Synced 2d ago

READMEChangelog (10)Dependencies (60)Versions (54)Used By (20)

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

[](#rector-rules)

[![Integrate](https://github.com/ergebnis/rector-rules/actions/workflows/integrate.yaml/badge.svg?branch=main)](https://github.com/ergebnis/rector-rules/actions/workflows/integrate.yaml)[![Merge](https://github.com/ergebnis/rector-rules/actions/workflows/merge.yaml/badge.svg)](https://github.com/ergebnis/rector-rules/actions/workflows/merge.yaml)[![Release](https://github.com/ergebnis/rector-rules/actions/workflows/release.yaml/badge.svg)](https://github.com/ergebnis/rector-rules/actions/workflows/release.yaml)[![Renew](https://github.com/ergebnis/rector-rules/actions/workflows/renew.yaml/badge.svg)](https://github.com/ergebnis/rector-rules/actions/workflows/renew.yaml)

[![Code Coverage](https://camo.githubusercontent.com/ed1727cca8c560308a2083de45b96d38797c277036775b0bbbfd97ac16d96a42/68747470733a2f2f636f6465636f762e696f2f67682f65726765626e69732f726563746f722d72756c65732f6272616e63682f6d61696e2f67726170682f62616467652e737667)](https://codecov.io/gh/ergebnis/rector-rules)

[![Latest Stable Version](https://camo.githubusercontent.com/fce8b65c225a5e45d60499d8df8e6b719cf750ed89759910f517c102d9707782/68747470733a2f2f706f7365722e707567782e6f72672f65726765626e69732f726563746f722d72756c65732f762f737461626c65)](https://packagist.org/packages/ergebnis/rector-rules)[![Total Downloads](https://camo.githubusercontent.com/998f5bf9b35249e1085f2afb244cc430b2f06c0bbb2213a54f27fe5e04029bc0/68747470733a2f2f706f7365722e707567782e6f72672f65726765626e69732f726563746f722d72756c65732f646f776e6c6f616473)](https://packagist.org/packages/ergebnis/rector-rules)[![Monthly Downloads](https://camo.githubusercontent.com/8531089e81dacfa56539657d1f1d24820ba997c92efbef536c732aafe81f32b5/687474703a2f2f706f7365722e707567782e6f72672f65726765626e69732f726563746f722d72756c65732f642f6d6f6e74686c79)](https://packagist.org/packages/ergebnis/rector-rules)

This project provides a [`composer`](https://getcomposer.org) package with rules for [`rector/rector`](https://github.com/rectorphp/rector).

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

[](#installation)

Run

```
composer require --dev ergebnis/rector-rules
```

Rules
-----

[](#rules)

This project provides the following rules for [`rector/rector`](https://github.com/rectorphp/rector):

- [`Ergebnis\Rector\Rules\Expressions\Arrays\SortAssociativeArrayByKeyRector`](#expressionsarrayssortassociativearraybykeyrector)
- [`Ergebnis\Rector\Rules\Expressions\CallLikes\RemoveNamedArgumentForSingleParameterRector`](#expressionscalllikesremovenamedargumentforsingleparameterrector)
- [`Ergebnis\Rector\Rules\Expressions\Matches\SortMatchArmsByConditionalRector`](#expressionsmatchessortmatcharmsbyconditionalrector)
- [`Ergebnis\Rector\Rules\Faker\GeneratorPropertyFetchToMethodCallRector`](#fakergeneratorpropertyfetchtomethodcallrector)
- [`Ergebnis\Rector\Rules\Files\ReferenceNamespacedSymbolsRelativeToNamespacePrefixRector`](#filesreferencenamespacedsymbolsrelativetonamespaceprefixrector)
- [`Ergebnis\Rector\Rules\PHPUnit\ReplaceTestAttributeWithTestPrefixRector`](#phpunitreplacetestattributewithtestprefixrector)

### Expressions\\Arrays

[](#expressionsarrays)

#### `Expressions\Arrays\SortAssociativeArrayByKeyRector`

[](#expressionsarrayssortassociativearraybykeyrector)

Sorts associative arrays by key.

```
 $data = [
+    'bar' => [
+        'quux' => 'quuz',
+        'quz' => 'qux',
+    ],
     'foo' => [
         'foo',
         'bar',
         'baz',
-    ],
-    'bar' => [
-        'quz' => 'qux',
-        'quux' => 'quuz',
     ],
 ];
```

💡 Find out more in the rule documentation for [`Expressions\Arrays\SortAssociativeArrayByKeyRector`](doc/rules/Expressions/Arrays/SortAssociativeArrayByKeyRector.md).

### Expressions\\CallLikes

[](#expressionscalllikes)

#### `Expressions\CallLikes\RemoveNamedArgumentForSingleParameterRector`

[](#expressionscalllikesremovenamedargumentforsingleparameterrector)

Removes named arguments for single-parameter function and method calls.

```
-strlen(string: 'hello');
+strlen('hello');
```

💡 Find out more in the rule documentation for [`Expressions\CallLikes\RemoveNamedArgumentForSingleParameterRector`](doc/rules/Expressions/CallLikes/RemoveNamedArgumentForSingleParameterRector.md).

### Expressions\\Matches

[](#expressionsmatches)

#### `Expressions\Matches\SortMatchArmsByConditionalRector`

[](#expressionsmatchessortmatcharmsbyconditionalrector)

Sorts match arms by conditional when the conditionals are all integers or all strings.

```
 match ($status) {
-    'pending' => handlePending(),
     'active' => handleActive(),
     'closed' => handleClosed(),
+    'pending' => handlePending(),
 };
```

💡 Find out more in the rule documentation for [`Expressions\Matches\SortMatchArmsByConditionalRector`](doc/rules/Expressions/Matches/SortMatchArmsByConditionalRector.md).

### Faker

[](#faker)

#### `Faker\GeneratorPropertyFetchToMethodCallRector`

[](#fakergeneratorpropertyfetchtomethodcallrector)

Replaces references to deprecated properties of Faker\\Generator with method calls.

```
-$faker->address;
+$faker->address();
```

💡 Find out more in the rule documentation for [`Faker\GeneratorPropertyFetchToMethodCallRector`](doc/rules/Faker/GeneratorPropertyFetchToMethodCallRector.md).

### Files

[](#files)

#### `Files\ReferenceNamespacedSymbolsRelativeToNamespacePrefixRector`

[](#filesreferencenamespacedsymbolsrelativetonamespaceprefixrector)

Replaces references to namespaced symbols (classes, functions, constants) whose fully-qualified name starts with a namespace prefix so they are relative to that prefix.

```
-use Foo\Bar;
-use Foo\Bar\Baz\Qux;
+use Foo\Bar\Baz;

-new Bar\Baz\Qux\Quuz();
-new Qux\Quuz\Grauply();
+new Baz\Qux\Quuz();
+new Baz\Qux\Quuz\Grauply();
```

💡 Find out more in the rule documentation for [`Files\ReferenceNamespacedSymbolsRelativeToNamespacePrefixRector`](doc/rules/Files/ReferenceNamespacedSymbolsRelativeToNamespacePrefixRector.md).

### PHPUnit

[](#phpunit)

#### `PHPUnit\ReplaceTestAttributeWithTestPrefixRector`

[](#phpunitreplacetestattributewithtestprefixrector)

Replaces #\[Test\] attributes with test method prefixes.

```
 use PHPUnit\Framework;

 final class SomeTest extends Framework\TestCase
 {
-    #[Framework\Attributes\Test]
-    public function onePlusOneShouldBeTwo(): void
+    public function testOnePlusOneShouldBeTwo(): void
     {
         self::assertSame(2, 1 + 1);
     }
 }
```

💡 Find out more in the rule documentation for [`PHPUnit\ReplaceTestAttributeWithTestPrefixRector`](doc/rules/PHPUnit/ReplaceTestAttributeWithTestPrefixRector.md).

Changelog
---------

[](#changelog)

The maintainers of this project record notable changes to this project in a [changelog](CHANGELOG.md).

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

[](#contributing)

The maintainers of this project suggest following the [contribution guide](.github/CONTRIBUTING.md).

Code of Conduct
---------------

[](#code-of-conduct)

The maintainers of this project ask contributors to follow the [code of conduct](https://github.com/ergebnis/.github/blob/main/CODE_OF_CONDUCT.md).

General Support Policy
----------------------

[](#general-support-policy)

The maintainers of this project provide limited support.

You can support the maintenance of this project by [sponsoring @ergebnis](https://github.com/sponsors/ergebnis).

PHP Version Support Policy
--------------------------

[](#php-version-support-policy)

This project currently supports the following PHP versions:

- [PHP 7.4](https://www.php.net/releases/#7.4.0) (has reached its end of life on November 28, 2022)
- [PHP 8.0](https://www.php.net/releases/#8.0.0) (has reached its end of life on November 26, 2023)
- [PHP 8.1](https://www.php.net/releases/#8.1.0) (has reached its end of life on December 31, 2025)
- [PHP 8.2](https://www.php.net/releases/#8.2.0)
- [PHP 8.3](https://www.php.net/releases/#8.3.0)
- [PHP 8.4](https://www.php.net/releases/#8.4.0)
- [PHP 8.5](https://www.php.net/releases/#8.5.0)

The maintainers of this project add support for a PHP version following its initial release and *may* drop support for a PHP version when it has reached its [end of life](https://www.php.net/supported-versions.php).

Security Policy
---------------

[](#security-policy)

This project has a [security policy](.github/SECURITY.md).

License
-------

[](#license)

This project uses the [MIT license](LICENSE.md).

Social
------

[](#social)

Follow [@localheinz](https://twitter.com/intent/follow?screen_name=localheinz) and [@ergebnis](https://twitter.com/intent/follow?screen_name=ergebnis) on Twitter.

###  Health Score

63

—

FairBetter than 99% of packages

Maintenance99

Actively maintained with recent releases

Popularity41

Moderate usage in the ecosystem

Community25

Small or concentrated contributor base

Maturity74

Established project with proven stability

 Bus Factor2

2 contributors hold 50%+ of commits

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 ~27 days

Recently: every ~20 days

Total

38

Last Release

11d ago

Major Versions

0.4.0 → 1.0.02024-02-06

PHP version history (5 changes)0.1.0PHP ~8.1.0 || ~8.2.0

0.2.0PHP ~8.1.0 || ~8.2.0 || ~8.3.0

0.3.0PHP ~7.4.0 || ~8.0.0 || ~8.1.0 || ~8.2.0 || ~8.3.0

1.1.0PHP ~7.4.0 || ~8.0.0 || ~8.1.0 || ~8.2.0 || ~8.3.0 || ~8.4.0

1.6.0PHP ~7.4.0 || ~8.0.0 || ~8.1.0 || ~8.2.0 || ~8.3.0 || ~8.4.0 || ~8.5.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/8cabc9efd157e2b47aa5aa9830180f5ebd07813cc3e93ff1a9993b2c3d264909?d=identicon)[localheinz](/maintainers/localheinz)

---

Top Contributors

[![localheinz](https://avatars.githubusercontent.com/u/605483?v=4)](https://github.com/localheinz "localheinz (340 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (238 commits)")[![ergebnis-bot](https://avatars.githubusercontent.com/u/59560144?v=4)](https://github.com/ergebnis-bot "ergebnis-bot (204 commits)")

---

Tags

rectorrules

###  Code Quality

TestsPHPUnit

Type Coverage Yes

### Embed Badge

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

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

###  Alternatives

[tempest/framework

The PHP framework that gets out of your way.

2.2k34.4k15](/packages/tempest-framework)[ssch/typo3-rector

Instant fixes for your TYPO3 PHP code by using Rector.

2603.2M435](/packages/ssch-typo3-rector)[deptrac/deptrac

Deptrac is a static code analysis tool that helps to enforce rules for dependencies between software layers.

3.0k8.8M118](/packages/deptrac-deptrac)[psalm/plugin-laravel

Psalm plugin for Laravel

3355.3M346](/packages/psalm-plugin-laravel)[rector/rector-src

Instant Upgrade and Automated Refactoring of any PHP code

136406.3k14](/packages/rector-rector-src)[v.chetkov/php-clean-architecture

PHP Clean Architecture

14661.1k](/packages/vchetkov-php-clean-architecture)

PHPackages © 2026

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