ergebnis/rector-rules
A curated set of custom Rector rules from ergebnis to automate PHP refactoring and style consistency. Includes rules for sorting arrays and match arms, simplifying call arguments, Faker updates, namespace symbol references, and PHPUnit attribute-to-prefix changes.
Expressions\Matches\SortMatchArmsByConditionalRectorSorts match arms by conditional when the conditionals are all integers or all strings.
comparison_functionThe comparison function to use for sorting conditionals when conditionals are strings.
string'strcasecmp', 'strcmp', 'strnatcasecmp', 'strnatcmp''strcmp'directionThe sorting direction.
string'asc', 'desc''asc' match ($status) {
- 'pending' => handlePending(),
'active' => handleActive(),
'closed' => handleClosed(),
+ 'pending' => handlePending(),
};
match ($status) {
+ 'active' => handleActive(),
+ 'closed' => handleClosed(),
'pending' => handlePending(),
default => handleUnknown(),
- 'active' => handleActive(),
- 'closed' => handleClosed(),
};
match (true) {
- Zebra::class => handleZebra(),
Apple::class => handleApple(),
Mango::class => handleMango(),
+ Zebra::class => handleZebra(),
};
match (true) {
+ Apple::class => handleApple(),
+ Mango::class => handleMango(),
Zebra::class => handleZebra(),
default => handleUnknown(),
- Apple::class => handleApple(),
- Mango::class => handleMango(),
};
match ($code) {
+ 200 => 'OK',
404 => 'Not Found',
+ 500 => 'Server Error',
default => 'Unknown',
- 200 => 'OK',
- 500 => 'Server Error',
};
Configuration:
direction: 'desc' match ($status) {
- 'active' => handleActive(),
'pending' => handlePending(),
'closed' => handleClosed(),
+ 'active' => handleActive(),
};
Configuration:
comparison_function: 'strcasecmp' match ($status) {
- 'Pending' => handlePending(),
'active' => handleActive(),
'Closed' => handleClosed(),
+ 'Pending' => handlePending(),
};
Configuration:
comparison_function: 'strnatcmp' match ($status) {
+ 'Status' => handleBase(),
+ 'Status2' => handle2(),
'Status10' => handle10(),
- 'Status2' => handle2(),
- 'Status' => handleBase(),
};
Configuration:
comparison_function: 'strnatcasecmp' match ($status) {
+ 'Status' => handleBase(),
+ 'status2' => handle2(),
'Status10' => handle10(),
- 'status2' => handle2(),
- 'Status' => handleBase(),
};
How can I help you explore Laravel packages today?