|
1 | | -# 80 Rules Overview |
| 1 | +# 83 Rules Overview |
2 | 2 |
|
3 | 3 | ## AbortIfRector |
4 | 4 |
|
@@ -59,28 +59,6 @@ Adds the `@extends` annotation to Factories. |
59 | 59 |
|
60 | 60 | <br> |
61 | 61 |
|
62 | | -## AddHasFactoryToModelsRector |
63 | | - |
64 | | -Adds the `HasFactory` trait to Models. |
65 | | - |
66 | | -:wrench: **configure it!** |
67 | | - |
68 | | -- class: [`RectorLaravel\Rector\Class_\AddHasFactoryToModelsRector`](../src/Rector/Class_/AddHasFactoryToModelsRector.php) |
69 | | - |
70 | | -```diff |
71 | | - namespace App\Models; |
72 | | - |
73 | | - use Illuminate\Database\Eloquent\Factories\Factory; |
74 | | - use Illuminate\Database\Eloquent\Model; |
75 | | - |
76 | | - class User extends Model |
77 | | - { |
78 | | -+ use \Illuminate\Database\Eloquent\Factories\HasFactory; |
79 | | - } |
80 | | -``` |
81 | | - |
82 | | -<br> |
83 | | - |
84 | 62 | ## AddGenericReturnTypeToRelationsRector |
85 | 63 |
|
86 | 64 | Add generic return type to relations in child of `Illuminate\Database\Eloquent\Model` |
@@ -143,6 +121,25 @@ Add new `$guard` argument to Illuminate\Auth\Events\Login |
143 | 121 |
|
144 | 122 | <br> |
145 | 123 |
|
| 124 | +## AddHasFactoryToModelsRector |
| 125 | + |
| 126 | +Adds the HasFactory trait to Models. |
| 127 | + |
| 128 | +:wrench: **configure it!** |
| 129 | + |
| 130 | +- class: [`RectorLaravel\Rector\Class_\AddHasFactoryToModelsRector`](../src/Rector/Class_/AddHasFactoryToModelsRector.php) |
| 131 | + |
| 132 | +```diff |
| 133 | + use Illuminate\Database\Eloquent\Model; |
| 134 | + |
| 135 | + class User extends Model |
| 136 | + { |
| 137 | ++ use \Illuminate\Database\Eloquent\Factories\HasFactory; |
| 138 | + } |
| 139 | +``` |
| 140 | + |
| 141 | +<br> |
| 142 | + |
146 | 143 | ## AddMockConsoleOutputFalseToConsoleTestsRector |
147 | 144 |
|
148 | 145 | Add "$this->mockConsoleOutput = false"; to console tests that work with output content |
@@ -502,6 +499,36 @@ Refactor `whereDate()` queries to include both date and time comparisons with Ca |
502 | 499 |
|
503 | 500 | <br> |
504 | 501 |
|
| 502 | +## ContainerBindConcreteWithClosureOnlyRector |
| 503 | + |
| 504 | +Drop the specified abstract class from the bind method and replace it with a closure that returns the abstract class. |
| 505 | + |
| 506 | +- class: [`RectorLaravel\Rector\MethodCall\ContainerBindConcreteWithClosureOnlyRector`](../src/Rector/MethodCall/ContainerBindConcreteWithClosureOnlyRector.php) |
| 507 | + |
| 508 | +```diff |
| 509 | +-$this->app->bind(SomeClass::class, function (): SomeClass { |
| 510 | ++$this->app->bind(function (): SomeClass { |
| 511 | + return new SomeClass(); |
| 512 | + }); |
| 513 | +``` |
| 514 | + |
| 515 | +<br> |
| 516 | + |
| 517 | +## ConvertEnumerableToArrayToAllRector |
| 518 | + |
| 519 | +Convert `toArray()` to `all()` when the collection does not contain any Arrayable objects. |
| 520 | + |
| 521 | +- class: [`RectorLaravel\Rector\MethodCall\ConvertEnumerableToArrayToAllRector`](../src/Rector/MethodCall/ConvertEnumerableToArrayToAllRector.php) |
| 522 | + |
| 523 | +```diff |
| 524 | + use Illuminate\Support\Collection; |
| 525 | + |
| 526 | +-new Collection([0, 1, -1])->toArray(); |
| 527 | ++new Collection([0, 1, -1])->all(); |
| 528 | +``` |
| 529 | + |
| 530 | +<br> |
| 531 | + |
505 | 532 | ## DatabaseExpressionCastsToMethodCallRector |
506 | 533 |
|
507 | 534 | Convert DB Expression string casts to `getValue()` method calls. |
|
0 commit comments