Skip to content

Commit be9b827

Browse files
committed
install rector-laravel
1 parent a23e089 commit be9b827

File tree

8 files changed

+264
-8
lines changed

8 files changed

+264
-8
lines changed

app/Models/User.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,14 @@
33
namespace App\Models;
44

55
// use Illuminate\Contracts\Auth\MustVerifyEmail;
6+
use Database\Factories\UserFactory;
67
use Illuminate\Database\Eloquent\Factories\HasFactory;
78
use Illuminate\Foundation\Auth\User as Authenticatable;
89
use Illuminate\Notifications\Notifiable;
910

1011
class User extends Authenticatable
1112
{
12-
/** @use HasFactory<\Database\Factories\UserFactory> */
13+
/** @use HasFactory<UserFactory> */
1314
use HasFactory, Notifiable;
1415

1516
/**

bootstrap/app.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@
1010
commands: __DIR__.'/../routes/console.php',
1111
health: '/up',
1212
)
13-
->withMiddleware(function (Middleware $middleware) {
13+
->withMiddleware(function (Middleware $middleware): void {
1414
//
1515
})
16-
->withExceptions(function (Exceptions $exceptions) {
16+
->withExceptions(function (Exceptions $exceptions): void {
1717
//
1818
})->create();

bootstrap/providers.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
<?php
22

3+
use App\Providers\AppServiceProvider;
4+
35
return [
4-
App\Providers\AppServiceProvider::class,
6+
AppServiceProvider::class,
57
];

composer.json

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
"laravel/tinker": "^2.10.1"
1515
},
1616
"require-dev": {
17+
"driftingly/rector-laravel": "^2.0",
1718
"fakerphp/faker": "^1.23",
1819
"laravel/pail": "^1.2.2",
1920
"laravel/pint": "^1.13",
@@ -57,6 +58,10 @@
5758
"test": [
5859
"@php artisan config:clear --ansi",
5960
"@php artisan test"
61+
],
62+
"format": [
63+
"vendor/bin/rector process",
64+
"vendor/bin/pint"
6065
]
6166
},
6267
"extra": {
@@ -75,4 +80,4 @@
7580
},
7681
"minimum-stability": "stable",
7782
"prefer-stable": true
78-
}
83+
}

composer.lock

Lines changed: 153 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

config/auth.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
<?php
22

3+
use App\Models\User;
4+
35
return [
46

57
/*
@@ -62,7 +64,7 @@
6264
'providers' => [
6365
'users' => [
6466
'driver' => 'eloquent',
65-
'model' => env('AUTH_MODEL', App\Models\User::class),
67+
'model' => env('AUTH_MODEL', User::class),
6668
],
6769

6870
// 'users' => [

rector.php

Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
use Rector\Config\RectorConfig;
6+
use Rector\Set\ValueObject\SetList;
7+
use Rector\ValueObject\PhpVersion;
8+
use RectorLaravel\Rector\Class_\AnonymousMigrationsRector;
9+
use RectorLaravel\Rector\ClassMethod\AddGenericReturnTypeToRelationsRector;
10+
use RectorLaravel\Rector\Coalesce\ApplyDefaultInsteadOfNullCoalesceRector;
11+
use RectorLaravel\Rector\Expr\AppEnvironmentComparisonToParameterRector;
12+
use RectorLaravel\Rector\Expr\SubStrToStartsWithOrEndsWithStaticMethodCallRector\SubStrToStartsWithOrEndsWithStaticMethodCallRector;
13+
use RectorLaravel\Rector\FuncCall\NotFilledBlankFuncCallToBlankFilledFuncCallRector;
14+
use RectorLaravel\Rector\FuncCall\NowFuncWithStartOfDayMethodCallToTodayFuncRector;
15+
use RectorLaravel\Rector\FuncCall\RemoveDumpDataDeadCodeRector;
16+
use RectorLaravel\Rector\FuncCall\ThrowIfAndThrowUnlessExceptionsToUseClassStringRector;
17+
use RectorLaravel\Rector\FuncCall\TypeHintTappableCallRector;
18+
use RectorLaravel\Rector\If_\AbortIfRector;
19+
use RectorLaravel\Rector\If_\ReportIfRector;
20+
use RectorLaravel\Rector\If_\ThrowIfRector;
21+
use RectorLaravel\Rector\MethodCall\EloquentOrderByToLatestOrOldestRector;
22+
use RectorLaravel\Rector\MethodCall\EloquentWhereRelationTypeHintingParameterRector;
23+
use RectorLaravel\Rector\MethodCall\EloquentWhereTypeHintClosureParameterRector;
24+
use RectorLaravel\Rector\MethodCall\RedirectBackToBackHelperRector;
25+
use RectorLaravel\Rector\MethodCall\RedirectRouteToToRouteHelperRector;
26+
use RectorLaravel\Rector\MethodCall\ValidationRuleArrayStringValueToArrayRector;
27+
use RectorLaravel\Rector\MethodCall\WhereToWhereLikeRector;
28+
use RectorLaravel\Rector\PropertyFetch\OptionalToNullsafeOperatorRector;
29+
use RectorLaravel\Rector\StaticCall\CarbonSetTestNowToTravelToRector;
30+
use RectorLaravel\Rector\StaticCall\DispatchToHelperFunctionsRector;
31+
use RectorLaravel\Rector\StaticCall\EloquentMagicMethodToQueryBuilderRector;
32+
use RectorLaravel\Rector\StaticCall\MinutesToSecondsInCacheRector;
33+
use RectorLaravel\Rector\StaticCall\RequestStaticValidateToInjectRector;
34+
use RectorLaravel\Rector\StaticCall\RouteActionCallableRector;
35+
use RectorLaravel\Set\LaravelLevelSetList;
36+
use RectorLaravel\Set\LaravelSetList;
37+
38+
return RectorConfig::configure()
39+
->withPaths([
40+
__DIR__.'/app',
41+
__DIR__.'/bootstrap',
42+
__DIR__.'/config',
43+
__DIR__.'/public',
44+
__DIR__.'/resources',
45+
__DIR__.'/routes',
46+
__DIR__.'/tests',
47+
])
48+
// uncomment to reach your current PHP version
49+
->withPreparedSets(
50+
deadCode: true,
51+
codeQuality: true,
52+
typeDeclarations: true,
53+
privatization: true,
54+
earlyReturn: true,
55+
strictBooleans: true
56+
)
57+
->withSets([
58+
SetList::DEAD_CODE,
59+
LaravelLevelSetList::UP_TO_LARAVEL_120,
60+
LaravelSetList::LARAVEL_LEGACY_FACTORIES_TO_CLASSES,
61+
LaravelSetList::LARAVEL_CODE_QUALITY,
62+
LaravelSetList::LARAVEL_COLLECTION,
63+
])
64+
->withRules([
65+
AnonymousMigrationsRector::class,
66+
EloquentMagicMethodToQueryBuilderRector::class,
67+
EloquentOrderByToLatestOrOldestRector::class,
68+
AbortIfRector::class,
69+
ReportIfRector::class,
70+
ThrowIfRector::class,
71+
RedirectRouteToToRouteHelperRector::class,
72+
EloquentWhereRelationTypeHintingParameterRector::class,
73+
EloquentWhereTypeHintClosureParameterRector::class,
74+
ValidationRuleArrayStringValueToArrayRector::class,
75+
RedirectBackToBackHelperRector::class,
76+
WhereToWhereLikeRector::class,
77+
NowFuncWithStartOfDayMethodCallToTodayFuncRector::class,
78+
ThrowIfAndThrowUnlessExceptionsToUseClassStringRector::class,
79+
TypeHintTappableCallRector::class,
80+
NotFilledBlankFuncCallToBlankFilledFuncCallRector::class,
81+
RemoveDumpDataDeadCodeRector::class,
82+
CarbonSetTestNowToTravelToRector::class,
83+
MinutesToSecondsInCacheRector::class,
84+
DispatchToHelperFunctionsRector::class,
85+
RequestStaticValidateToInjectRector::class,
86+
RouteActionCallableRector::class,
87+
OptionalToNullsafeOperatorRector::class,
88+
SubStrToStartsWithOrEndsWithStaticMethodCallRector::class,
89+
AppEnvironmentComparisonToParameterRector::class,
90+
ApplyDefaultInsteadOfNullCoalesceRector::class,
91+
AddGenericReturnTypeToRelationsRector::class,
92+
])
93+
->withImportNames(removeUnusedImports: true)
94+
->withPhpVersion(PhpVersion::PHP_82);

routes/console.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,6 @@
33
use Illuminate\Foundation\Inspiring;
44
use Illuminate\Support\Facades\Artisan;
55

6-
Artisan::command('inspire', function () {
6+
Artisan::command('inspire', function (): void {
77
$this->comment(Inspiring::quote());
88
})->purpose('Display an inspiring quote');

0 commit comments

Comments
 (0)