ergebnis / rector-rules
Provides rules for rector/rector.
Requires
- php: ~7.4.0 || ~8.0.0 || ~8.1.0 || ~8.2.0 || ~8.3.0 || ~8.4.0 || ~8.5.0
- nikic/php-parser: ^4.17.1 || ^5.0.0
- phpstan/phpstan: ^2.0.0
- rector/rector: ^2.3.8
Requires (Dev)
- ergebnis/classy: ^3.0.0
- ergebnis/composer-normalize: ^2.50.0
- ergebnis/data-provider: ^3.6.0
- ergebnis/license: ^2.7.0
- ergebnis/php-cs-fixer-config: ^6.60.2
- ergebnis/phpunit-slow-test-detector: ^2.24.0
- phpstan/extension-installer: ^1.4.3
- phpstan/phpstan-deprecation-rules: ^2.0.4
- phpstan/phpstan-phpunit: ^2.0.16
- phpstan/phpstan-strict-rules: ^2.0.10
- phpunit/phpunit: ^9.6.33
- sebastian/diff: ^4.0.6
- symfony/filesystem: ^5.4.45
- symfony/finder: ^5.4.45
- dev-main
- 1.18.1
- 1.18.0
- 1.17.0
- 1.16.0
- 1.15.2
- 1.15.1
- 1.15.0
- 1.14.1
- 1.14.0
- 1.13.2
- 1.13.1
- 1.13.0
- 1.12.5
- 1.12.4
- 1.12.3
- 1.12.2
- 1.12.1
- 1.12.0
- 1.11.1
- 1.11.0
- 1.10.0
- 1.9.0
- 1.8.0
- 1.7.0
- 1.6.0
- 1.5.1
- 1.5.0
- 1.4.0
- 1.3.0
- 1.2.0
- 1.1.0
- 1.0.1
- 1.0.0
- 0.4.0
- 0.3.0
- 0.2.0
- 0.1.0
- dev-dependabot/composer/ergebnis/php-cs-fixer-config-6.61.1
- dev-dependabot/github_actions/actions/cache-5.0.5
- dev-fix/first-class-callable
- dev-feature/php-versions
- dev-feature/remove-named-argument-for-single-parameter
- dev-feature/remove-unused-trait-use-rector
This package is auto-updated.
Last update: 2026-04-13 23:46:20 UTC
README
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:
Ergebnis\Rector\Rules\Expressions\Arrays\SortAssociativeArrayByKeyRectorErgebnis\Rector\Rules\Expressions\CallLikes\RemoveNamedArgumentForSingleParameterRectorErgebnis\Rector\Rules\Expressions\Matches\SortMatchArmsByConditionalRectorErgebnis\Rector\Rules\Faker\GeneratorPropertyFetchToMethodCallRectorErgebnis\Rector\Rules\Files\ReferenceNamespacedSymbolsRelativeToNamespacePrefixRectorErgebnis\Rector\Rules\PHPUnit\ReplaceTestAttributeWithTestPrefixRector
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:
- PHP 7.4 (has reached its end of life on November 28, 2022)
- PHP 8.0 (has reached its end of life on November 26, 2023)
- PHP 8.1 (has reached its end of life on December 31, 2025)
- PHP 8.2
- PHP 8.3
- PHP 8.4
- PHP 8.5
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.