Find the best Rector rule to solve your problem. Searching through 678 rules.

Found 10 rules:

LumenRoutesStringActionToUsesArrayRector

Changes action in rule definitions from string to array notation.

-$router->get('/user', 'UserController@get');
+$router->get('/user', ['uses => 'UserController@get']);

DatabaseExpressionToStringToMethodCallRector

Convert DB Expression __toString() calls to getValue() method calls.

 use Illuminate\Support\Facades\DB;

-$string = DB::raw('select 1')->__toString();
+$string = DB::raw('select 1')->getValue(DB::connection()->getQueryGrammar());

UnaliasCollectionMethodsRector

Use the base collection methods instead of their aliases.

 use Illuminate\Support\Collection;

 $collection = new Collection([0, 1, null, -1]);
-$collection->average();
-$collection->some(fn (?int $number): bool => is_null($number));
+$collection->avg();
+$collection->contains(fn (?int $number): bool => is_null($number));

AssertStatusToAssertMethodRector

Replace (new \Illuminate\Testing\TestResponse)->assertStatus(200) with (new \Illuminate\Testing\TestResponse)->assertOk()

 class ExampleTest extends \Illuminate\Foundation\Testing\TestCase
 {
     public function testFoo()
     {
-        $this->get('/')->assertStatus(200);
-        $this->get('/')->assertStatus(204);
-        $this->get('/')->assertStatus(401);
-        $this->get('/')->assertStatus(403);
-        $this->get('/')->assertStatus(404);
-        $this->get('/')->assertStatus(405);
-        $this->get('/')->assertStatus(422);
-        $this->get('/')->assertStatus(410);
-        $this->get('/')->assertStatus(500);
-        $this->get('/')->assertStatus(503);
+        $this->get('/')->assertOk();
+        $this->get('/')->assertNoContent();
+        $this->get('/')->assertUnauthorized();
+        $this->get('/')->assertForbidden();
+        $this->get('/')->assertNotFound();
+        $this->get('/')->assertMethodNotAllowed();
+        $this->get('/')->assertUnprocessable();
+        $this->get('/')->assertGone();
+        $this->get('/')->assertInternalServerError();
+        $this->get('/')->assertServiceUnavailable();
     }
 }

ChangeQueryWhereDateValueWithCarbonRector

Refactor whereDate() queries to include both date and time comparisons with Carbon

 use Illuminate\Database\Query\Builder;

 final class SomeClass
 {
     public function run(Builder $query)
     {
-        $query->whereDate('created_at', '<', Carbon::now());
+        $dateTime = Carbon::now();
+        $query->whereDate('created_at', '<=', $dateTime);
+        $query->whereTime('created_at', '<=', $dateTime);
     }
 }

Configurable

ReplaceServiceContainerCallArgRector

Changes the string or class const used for a service container make call

-app('encrypter')->encrypt('...');
-\Illuminate\Support\Facades\Application::make('encrypter')->encrypt('...');
+app(Illuminate\Contracts\Encryption\Encrypter::class)->encrypt('...');
+\Illuminate\Support\Facades\Application::make(Illuminate\Contracts\Encryption\Encrypter::class)->encrypt('...');

Configurable

EloquentOrderByToLatestOrOldestRector

Changes orderBy() to latest() or oldest()

 use Illuminate\Database\Eloquent\Builder;

 $column = 'tested_at';

-$builder->orderBy('created_at');
-$builder->orderBy('created_at', 'desc');
-$builder->orderBy('submitted_at');
-$builder->orderByDesc('submitted_at');
-$builder->orderBy($allowed_variable_name);
+$builder->oldest();
+$builder->latest();
+$builder->oldest('submitted_at');
+$builder->latest('submitted_at');
+$builder->oldest($allowed_variable_name);
 $builder->orderBy($unallowed_variable_name);
 $builder->orderBy('unallowed_column_name');

LumenRoutesStringMiddlewareToArrayRector

Changes middlewares from rule definitions from string to array notation.

-$router->get('/user', ['middleware => 'test']);
-$router->post('/user', ['middleware => 'test|authentication']);
+$router->get('/user', ['middleware => ['test']]);
+$router->post('/user', ['middleware => ['test', 'authentication']]);

ReverseConditionableMethodCallRector

Reverse conditionable method calls

-$conditionable->when(!$condition, function () {});
+$conditionable->unless($condition, function () {});
SETS:  Code quality

RefactorBlueprintGeometryColumnsRector

refactors calls with the pre Laravel 11 methods for blueprint geometry columns

-$blueprint->point('coordinates')->spatialIndex();
+$blueprint->geometry('coordinates', 'point')->spatialIndex();