Skip to content

Commit 046517a

Browse files
authored
Rector (#115)
* Install Rector * Update Composer dependencies * Require PHP 8.4 * Create rector.php * Add Rector command * Run Rector * Run Pint * Update AppServiceProvider.php * Update test.yml
1 parent 2742ec4 commit 046517a

File tree

14 files changed

+263
-78
lines changed

14 files changed

+263
-78
lines changed

.cursor/rules/laravel-boost.mdc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ This application is a Laravel application and its main Laravel ecosystems packag
2424
- laravel/pint (PINT) - v1
2525
- pestphp/pest (PEST) - v3
2626
- phpunit/phpunit (PHPUNIT) - v11
27+
- rector/rector (RECTOR) - v2
2728
- @inertiajs/vue3 (INERTIA) - v2
2829
- @laravel/vite-plugin-wayfinder (WAYFINDER) - v0
2930
- tailwindcss (TAILWINDCSS) - v4

.github/workflows/test.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,9 @@ jobs:
3939
- name: Build Assets
4040
run: composer assets:build
4141

42+
- name: Run Rector
43+
run: composer rector --dry-run
44+
4245
- name: Run Linter
4346
run: composer lint
4447

app/Http/Controllers/RegisterController.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,6 @@ public function store(RegisterStoreRequest $request)
3434

3535
event(new Registered($user));
3636

37-
return redirect()->route('home');
37+
return to_route('home');
3838
}
3939
}

app/Http/Controllers/ResetPasswordController.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ public function store(ResetPasswordStoreRequest $request)
3131

3232
session()->flash('success', __('passwords.sent'));
3333

34-
return redirect()->route('login');
34+
return to_route('login');
3535
}
3636

3737
public function edit(Request $request, string $token)
@@ -60,6 +60,6 @@ public function update(ResetPasswordUpdateRequest $request)
6060

6161
session()->flash('success', __('passwords.reset'));
6262

63-
return redirect()->route('login');
63+
return to_route('login');
6464
}
6565
}

app/Models/User.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,8 @@ protected function allPermissions(): Attribute
5656
);
5757
}
5858

59-
protected function scopeHasRoles(Builder $query, array $roles): void
59+
#[\Illuminate\Database\Eloquent\Attributes\Scope]
60+
protected function hasRoles(Builder $query, array $roles): void
6061
{
6162
$query->whereHas('roles', fn (Builder $query) => $query->whereIn('name', $roles));
6263
}

app/Providers/AppServiceProvider.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ class AppServiceProvider extends ServiceProvider
2121
{
2222
public function boot(): void
2323
{
24-
URL::forceHttps(in_array(app()->environment(), [Environment::PRODUCTION, Environment::STAGING]));
24+
URL::forceHttps(app()->environment([Environment::PRODUCTION->value, Environment::STAGING->value]));
2525

2626
RequestException::dontTruncate();
2727

composer.json

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"description": "A starter project for Laravel apps using Inertia and Vue.",
55
"license": "MIT",
66
"require": {
7-
"php": "^8.2",
7+
"php": "^8.4",
88
"filament/filament": "^4.0",
99
"inertiajs/inertia-laravel": "^2.0",
1010
"laravel/framework": "^12.0",
@@ -20,6 +20,7 @@
2020
},
2121
"require-dev": {
2222
"barryvdh/laravel-debugbar": "^3.13",
23+
"driftingly/rector-laravel": "^2.1",
2324
"fakerphp/faker": "^1.23",
2425
"laravel/boost": "^1.8",
2526
"laravel/pint": "^1.17",
@@ -28,6 +29,7 @@
2829
"pestphp/pest": "^3.0",
2930
"pestphp/pest-plugin-faker": "^3.0",
3031
"pestphp/pest-plugin-laravel": "^3.0",
32+
"rector/rector": "^2.2",
3133
"spatie/laravel-ray": "^1.37"
3234
},
3335
"autoload": {
@@ -58,6 +60,9 @@
5860
"build:test": [
5961
"composer install --no-interaction"
6062
],
63+
"rector": [
64+
"./vendor/bin/rector"
65+
],
6166
"lint": [
6267
"./vendor/bin/pint --test"
6368
],

0 commit comments

Comments
 (0)