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\Arrays\SortAssociativeArrayByKeyRectorErgebnis\Rector\Rules\Faker\GeneratorPropertyFetchToMethodCallRectorErgebnis\Rector\Rules\Files\ReferenceNamespacedSymbolsRelativeToNamespacePrefixRector
This rule sorts associative arrays by key.
<?php
$data = [
+ 'bar' => [
+ 'quux' => 'quuz',
+ 'quz' => 'qux',
+ ],
'foo' => [
'foo',
'bar',
'baz',
],
- 'bar' => [
- 'quz' => 'qux',
- 'quux' => 'quuz',
- ],
];comparison_function: the comparison function, one of ('strcasecmp','strcmp','strnatcasecmp', or'strnatcmp'), defaults to'strcmp'direction: the sorting direction (one of'asc','desc'), defaults toasc
This rule replaces references to deprecated properties of Faker\Generator with method calls.
<?php
use Faker\Factory;
$faker = Factory::create();
- $faker->boolean;
+ $faker->boolean();This rule replaces references to namespaced symbols (classes, functions, constants) whose fully-qualified name starts with a namespace prefix so they are relative to that prefix.
<?php
namespace App;
-use Foo\Bar;
-use Foo\Bar\Baz\Qux;
+use Foo\Bar\Baz;
-new Bar\Baz\Qux\Quuz();
-new Qux\Quuz\Grauply();
-new \Foo\Bar\Baz\Qux\Quuz();
+new Baz\Qux\Quuz();
+new Baz\Qux\Quuz\Grauply();
+new Baz\Qux\Quuz();discoverNamespacePrefixes: a boolean (defaultfalse) that automatically discovers parent namespace prefixes by scanning the file's references (use statements, fully-qualified names, docblocks, namespace declaration) and extracting their first segment (e.g.,SymfonyfromSymfony\Component\HttpFoundation\Request), then feeds them into theparentNamespacePrefixesdiscovery mechanismforceRelativeReferences: a boolean (defaultfalse) that forces references to be expressed relative to the namespace prefix even when the file namespace matches the prefixnamespacePrefixes: a list of namespace prefixes to consolidate (e.g.,['Foo\Bar\Baz', 'Example\Domain'])parentNamespacePrefixes: a list of parent namespace prefixes for automatic discovery of namespace prefixes per file (e.g.,['Foo\Bar']will discoverFoo\Bar\Bazas a namespace prefix when a file references symbols underFoo\Bar\Baz)
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 supports PHP versions with active and security support.
The maintainers of this project add support for a PHP version following its initial release and drop support for a PHP version when it has reached the end of security support.
This project has a security policy.
This project uses the MIT license.
Follow @localheinz and @ergebnis on Twitter.