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/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
- dev-main
- 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-fix/remove-prefix-import-when-file-namespace-matches-prefix
- dev-feature/force-relative-reference
- dev-fix/list
- dev-fix/update-descriptions
- dev-fix/parent
- dev-fix/namespace
- dev-feature/parent-namespace-prefixes
- dev-feature/namespace-prefix
- dev-dependabot/github_actions/ergebnis/dot-github-1.11.0
- dev-dependabot/composer/ergebnis/phpunit-slow-test-detector-2.24.0
- dev-dependabot/github_actions/shivammathur/setup-php-2.37.0
- dev-fix/use-group
- dev-fix/use
- dev-enhancement/namespace-prefix-value-object
- dev-fix/namespaced-symbol
- dev-feature/remove-unused-trait-use-rector
- dev-feature/relative-import-rector
This package is auto-updated.
Last update: 2026-03-18 13:59:57 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\Arrays\SortAssociativeArrayByKeyRectorErgebnis\Rector\Rules\Faker\GeneratorPropertyFetchToMethodCallRectorErgebnis\Rector\Rules\Files\ReferenceNamespacedSymbolsRelativeToNamespacePrefixRector
Arrays
Arrays\SortAssociativeArrayByKeyRector
This rule sorts associative arrays by key.
<?php $data = [ + 'bar' => [ + 'quux' => 'quuz', + 'quz' => 'qux', + ], 'foo' => [ 'foo', 'bar', 'baz', ], - 'bar' => [ - 'quz' => 'qux', - 'quux' => 'quuz', - ], ];
Configuration
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
Faker
Faker\GeneratorPropertyFetchToMethodCallRector
This rule replaces references to deprecated properties of Faker\Generator with method calls.
<?php use Faker\Factory; $faker = Factory::create(); - $faker->boolean; + $faker->boolean();
Files
Files\ReferenceNamespacedSymbolsRelativeToNamespacePrefixRector
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();
Configuration
forceRelativeReferences: 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)
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 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.
Security Policy
This project has a security policy.
License
This project uses the MIT license.
Social
Follow @localheinz and @ergebnis on Twitter.