This project provides a composer package with rules for rector/rector.
Run
composer require --dev ergebnis/rector-rulesThis 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
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.
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.
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.
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.
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.
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.
The maintainers of this project record notable changes to this project in a changelog.
The maintainers of this project suggest following the contribution guide.
The maintainers of this project ask contributors to follow the code of conduct.
The maintainers of this project provide limited support.
You can support the maintenance of this project by sponsoring @ergebnis.
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.
This project has a security policy.
This project uses the MIT license.
Follow @localheinz and @ergebnis on Twitter.