Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Rector Rules Laravel Package

ergebnis/rector-rules

Custom Rector rules from Ergebnis to standardize and modernize PHP code. Includes sorting associative arrays and match arms, converting Faker generator property fetches to method calls, and fixing namespaced symbol references. Install via Composer for dev.

View on GitHub
Deep Wiki
Context7

rector-rules

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\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.

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.

Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
davejamesmiller/laravel-breadcrumbs
artisanry/parsedown
christhompsontldr/phpsdk
enqueue/dsn
bunny/bunny
enqueue/test
enqueue/null
enqueue/amqp-tools
milesj/emojibase
bower-asset/punycode
bower-asset/inputmask
bower-asset/jquery
bower-asset/yii2-pjax
laravel/nova
spatie/laravel-mailcoach
spatie/laravel-superseeder
laravel/liferaft
nst/json-test-suite
danielmiessler/sec-lists
jackalope/jackalope-transport