Skip to content

Commit c75ce35

Browse files
committed
feat: (LAR-77) Correction des messages composer phpstan
1 parent c512f79 commit c75ce35

File tree

12 files changed

+64
-37
lines changed

12 files changed

+64
-37
lines changed

app/Http/Controllers/Auth/VerifyEmailController.php

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,33 @@
11
<?php
22

3+
declare(strict_types=1);
4+
35
namespace App\Http\Controllers\Auth;
46

57
use App\Http\Controllers\Controller;
68
use Illuminate\Auth\Events\Verified;
79
use Illuminate\Foundation\Auth\EmailVerificationRequest;
810
use Illuminate\Http\RedirectResponse;
911

10-
class VerifyEmailController extends Controller
12+
final class VerifyEmailController extends Controller
1113
{
1214
/**
1315
* Mark the authenticated user's email address as verified.
1416
*/
1517
public function __invoke(EmailVerificationRequest $request): RedirectResponse
1618
{
17-
if ($request->user()->hasVerifiedEmail()) {
19+
$user = $request->user();
20+
21+
if ($user === null) {
22+
return redirect()->route('login');
23+
}
24+
25+
if ($user->hasVerifiedEmail()) {
1826
return redirect()->intended(route('dashboard', absolute: false).'?verified=1');
1927
}
2028

21-
if ($request->user()->markEmailAsVerified()) {
22-
event(new Verified($request->user()));
29+
if ($user->markEmailAsVerified()) {
30+
event(new Verified($user));
2331
}
2432

2533
return redirect()->intended(route('dashboard', absolute: false).'?verified=1');

app/Livewire/Forms/LoginForm.php

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,9 @@ class LoginForm extends Form
1616
public string $password = '';
1717
public bool $remember = false;
1818

19-
public function __construct(Component $component = null, $name = 'form')
19+
public function __construct(Component $component = null, string $name = 'form')
2020
{
21+
$component = $component ?? app(Component::class);
2122
parent::__construct($component, $name);
2223
}
2324

@@ -30,7 +31,7 @@ public function authenticate(): void
3031
{
3132
$this->ensureIsNotRateLimited();
3233

33-
if (! Auth::attempt(['email' => $this->email, 'password' => $this->password], $this->remember)) {
34+
if (!Auth::attempt(['email' => $this->email, 'password' => $this->password], $this->remember)) {
3435
RateLimiter::hit($this->throttleKey());
3536

3637
throw ValidationException::withMessages([
@@ -46,7 +47,7 @@ public function authenticate(): void
4647
*/
4748
protected function ensureIsNotRateLimited(): void
4849
{
49-
if (! RateLimiter::tooManyAttempts($this->throttleKey(), 5)) {
50+
if (!RateLimiter::tooManyAttempts($this->throttleKey(), 5)) {
5051
return;
5152
}
5253

@@ -67,6 +68,6 @@ protected function ensureIsNotRateLimited(): void
6768
*/
6869
protected function throttleKey(): string
6970
{
70-
return Str::transliterate(Str::lower($this->email).'|'.request()->ip());
71+
return Str::transliterate(Str::lower($this->email) . '|' . request()->ip());
7172
}
7273
}

app/Livewire/Pages/Auth/Login.php

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,21 @@
11
<?php
22

3+
declare(strict_types=1);
4+
35
namespace App\Livewire\Pages\Auth;
46

7+
use Illuminate\View\View;
58
use App\Livewire\Forms\LoginForm;
69
use Illuminate\Support\Facades\Session;
7-
use Livewire\Component;
810
use Livewire\Attributes\Layout;
11+
use Livewire\Component;
912

1013
// #[Layout('layouts.guest')]
11-
class Login extends Component
14+
final class Login extends Component
1215
{
1316
public LoginForm $form;
1417

15-
public function boot()
18+
public function boot(): void
1619
{
1720
$this->form = new LoginForm($this);
1821
}
@@ -32,8 +35,8 @@ public function login(): void
3235
$this->redirectIntended(route('dashboard'));
3336
}
3437

35-
public function render()
38+
public function render(): View
3639
{
3740
return view('livewire.pages.auth.login');
3841
}
39-
}
42+
}

app/Providers/VoltServiceProvider.php

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

3+
declare(strict_types=1);
4+
35
namespace App\Providers;
46

57
use Illuminate\Support\ServiceProvider;
68
use Livewire\Volt\Volt;
79

8-
class VoltServiceProvider extends ServiceProvider
10+
final class VoltServiceProvider extends ServiceProvider
911
{
1012
/**
1113
* Register services.

routes/auth.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
<?php
22

3+
declare(strict_types=1);
4+
35
use App\Http\Controllers\Auth\VerifyEmailController;
46
use Illuminate\Support\Facades\Route;
57
use Livewire\Volt\Volt;
68

7-
Route::middleware('guest')->group(function () {
9+
Route::middleware('guest')->group(function (): void {
810
Volt::route('register', 'pages.auth.register')
911
->name('register');
1012

@@ -18,7 +20,7 @@
1820
->name('password.reset');
1921
});
2022

21-
Route::middleware('auth')->group(function () {
23+
Route::middleware('auth')->group(function (): void {
2224
Volt::route('verify-email', 'pages.auth.verify-email')
2325
->name('verification.notice');
2426

routes/web.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,5 +86,4 @@
8686
Route::get('sponsors', [SponsoringController::class, 'sponsors'])->name('sponsors');
8787
Route::get('callback-payment', NotchPayCallBackController::class)->name('notchpay-callback');
8888

89-
90-
require __DIR__.'/auth.php';
89+
require __DIR__.'/auth.php';

tests/Feature/Auth/AuthenticationTest.php

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

3+
declare(strict_types=1);
4+
35
use App\Models\User;
46
use Livewire\Volt\Volt;
57

6-
test('login screen can be rendered', function () {
8+
test('login screen can be rendered', function (): void {
79
$response = $this->get('/login');
810

911
$response
1012
->assertOk()
1113
->assertSeeVolt('pages.auth.login');
1214
});
1315

14-
test('users can authenticate using the login screen', function () {
16+
test('users can authenticate using the login screen', function (): void {
1517
$user = User::factory()->create();
1618

1719
$component = Volt::test('pages.auth.login')
@@ -27,7 +29,7 @@
2729
$this->assertAuthenticated();
2830
});
2931

30-
test('users can not authenticate with invalid password', function () {
32+
test('users can not authenticate with invalid password', function (): void {
3133
$user = User::factory()->create();
3234

3335
$component = Volt::test('pages.auth.login')
@@ -43,7 +45,7 @@
4345
$this->assertGuest();
4446
});
4547

46-
test('navigation menu can be rendered', function () {
48+
test('navigation menu can be rendered', function (): void {
4749
$user = User::factory()->create();
4850

4951
$this->actingAs($user);
@@ -55,7 +57,7 @@
5557
->assertSeeVolt('layout.navigation');
5658
});
5759

58-
test('users can logout', function () {
60+
test('users can logout', function (): void {
5961
$user = User::factory()->create();
6062

6163
$this->actingAs($user);

tests/Feature/Auth/EmailVerificationTest.php

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

3+
declare(strict_types=1);
4+
35
use App\Models\User;
46
use Illuminate\Auth\Events\Verified;
57
use Illuminate\Support\Facades\Event;
68
use Illuminate\Support\Facades\URL;
79

8-
test('email verification screen can be rendered', function () {
10+
test('email verification screen can be rendered', function (): void {
911
$user = User::factory()->unverified()->create();
1012

1113
$response = $this->actingAs($user)->get('/verify-email');
1214

1315
$response->assertStatus(200);
1416
});
1517

16-
test('email can be verified', function () {
18+
test('email can be verified', function (): void {
1719
$user = User::factory()->unverified()->create();
1820

1921
Event::fake();
@@ -31,7 +33,7 @@
3133
$response->assertRedirect(route('dashboard', absolute: false).'?verified=1');
3234
});
3335

34-
test('email is not verified with invalid hash', function () {
36+
test('email is not verified with invalid hash', function (): void {
3537
$user = User::factory()->unverified()->create();
3638

3739
$verificationUrl = URL::temporarySignedRoute(

tests/Feature/Auth/PasswordConfirmationTest.php

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

3+
declare(strict_types=1);
4+
35
namespace Tests\Feature\Auth;
46

57
use App\Models\User;
68
use Livewire\Volt\Volt;
79

8-
test('confirm password screen can be rendered', function () {
10+
test('confirm password screen can be rendered', function (): void {
911
$user = User::factory()->create();
1012

1113
$response = $this->actingAs($user)->get('/confirm-password');
@@ -15,7 +17,7 @@
1517
->assertStatus(200);
1618
});
1719

18-
test('password can be confirmed', function () {
20+
test('password can be confirmed', function (): void {
1921
$user = User::factory()->create();
2022

2123
$this->actingAs($user);
@@ -30,7 +32,7 @@
3032
->assertHasNoErrors();
3133
});
3234

33-
test('password is not confirmed with invalid password', function () {
35+
test('password is not confirmed with invalid password', function (): void {
3436
$user = User::factory()->create();
3537

3638
$this->actingAs($user);

tests/Feature/Auth/PasswordResetTest.php

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,23 @@
11
<?php
22

3+
declare(strict_types=1);
4+
35
namespace Tests\Feature\Auth;
46

57
use App\Models\User;
68
use Illuminate\Auth\Notifications\ResetPassword;
79
use Illuminate\Support\Facades\Notification;
810
use Livewire\Volt\Volt;
911

10-
test('reset password link screen can be rendered', function () {
12+
test('reset password link screen can be rendered', function (): void {
1113
$response = $this->get('/forgot-password');
1214

1315
$response
1416
->assertSeeVolt('pages.auth.forgot-password')
1517
->assertStatus(200);
1618
});
1719

18-
test('reset password link can be requested', function () {
20+
test('reset password link can be requested', function (): void {
1921
Notification::fake();
2022

2123
$user = User::factory()->create();
@@ -27,7 +29,7 @@
2729
Notification::assertSentTo($user, ResetPassword::class);
2830
});
2931

30-
test('reset password screen can be rendered', function () {
32+
test('reset password screen can be rendered', function (): void {
3133
Notification::fake();
3234

3335
$user = User::factory()->create();
@@ -47,7 +49,7 @@
4749
});
4850
});
4951

50-
test('password can be reset with valid token', function () {
52+
test('password can be reset with valid token', function (): void {
5153
Notification::fake();
5254

5355
$user = User::factory()->create();

tests/Feature/Auth/PasswordUpdateTest.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
<?php
22

3+
declare(strict_types=1);
4+
35
namespace Tests\Feature\Auth;
46

57
use App\Models\User;
68
use Illuminate\Support\Facades\Hash;
79
use Livewire\Volt\Volt;
810

9-
test('password can be updated', function () {
11+
test('password can be updated', function (): void {
1012
$user = User::factory()->create();
1113

1214
$this->actingAs($user);
@@ -24,7 +26,7 @@
2426
$this->assertTrue(Hash::check('new-password', $user->refresh()->password));
2527
});
2628

27-
test('correct password must be provided to update password', function () {
29+
test('correct password must be provided to update password', function (): void {
2830
$user = User::factory()->create();
2931

3032
$this->actingAs($user);

tests/Feature/Auth/RegistrationTest.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,20 @@
11
<?php
22

3+
declare(strict_types=1);
4+
35
namespace Tests\Feature\Auth;
46

57
use Livewire\Volt\Volt;
68

7-
test('registration screen can be rendered', function () {
9+
test('registration screen can be rendered', function (): void {
810
$response = $this->get('/register');
911

1012
$response
1113
->assertOk()
1214
->assertSeeVolt('pages.auth.register');
1315
});
1416

15-
test('new users can register', function () {
17+
test('new users can register', function (): void {
1618
$component = Volt::test('pages.auth.register')
1719
->set('name', 'Test User')
1820
->set('email', 'test@example.com')

0 commit comments

Comments
 (0)