ergebnis/rector-rules

Provides rules for rector/rector.

Maintainers

πŸ‘ localheinz

Package info

github.com/ergebnis/rector-rules

pkg:composer/ergebnis/rector-rules

Statistics

Installs: 235 551

Dependents: 36

Suggesters: 0

Stars: 10

Open Issues: 2

1.18.1 2026-04-13 16:13 UTC

Requires

Suggests

None

Provides

None

Conflicts

None

Replaces

None

MIT db1dd5b5f928f89b17392e7915f5e8458bd46df3


README

πŸ‘ Integrate
πŸ‘ Merge
πŸ‘ Release
πŸ‘ Renew

πŸ‘ Code Coverage

πŸ‘ Latest Stable Version
πŸ‘ Total Downloads
πŸ‘ Monthly Downloads

This project provides a composer package with rules for rector/rector.

Installation

Run

composer require --dev ergebnis/rector-rules

Rules

This project provides the following rules for rector/rector:

Expressions\Arrays

Expressions\Arrays\SortAssociativeArrayByKeyRector

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.

Expressions\CallLikes

Expressions\CallLikes\RemoveNamedArgumentForSingleParameterRector

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.

Expressions\Matches

Expressions\Matches\SortMatchArmsByConditionalRector

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.

Faker

Faker\GeneratorPropertyFetchToMethodCallRector

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.

Files

Files\ReferenceNamespacedSymbolsRelativeToNamespacePrefixRector

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.

PHPUnit

PHPUnit\ReplaceTestAttributeWithTestPrefixRector

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.

Changelog

The maintainers of this project record notable changes to this project in a changelog.

Contributing

The maintainers of this project suggest following the contribution guide.

Code of Conduct

The maintainers of this project ask contributors to follow the code of conduct.

General Support Policy

The maintainers of this project provide limited support.

You can support the maintenance of this project by sponsoring @ergebnis.

PHP Version Support Policy

This project currently supports the following PHP versions:

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.

Security Policy

This project has a security policy.

License

This project uses the MIT license.

Social

Follow @localheinz and @ergebnis on Twitter.