diff --git a/app/Livewire/Actions/Logout.php b/app/Livewire/Actions/Logout.php index 45993bb..c26fa72 100644 --- a/app/Livewire/Actions/Logout.php +++ b/app/Livewire/Actions/Logout.php @@ -10,7 +10,7 @@ class Logout /** * Log the current user out of the application. */ - public function __invoke() + public function __invoke(): \Illuminate\Routing\Redirector|\Illuminate\Http\RedirectResponse { Auth::guard('web')->logout(); diff --git a/app/Livewire/Auth/ResetPassword.php b/app/Livewire/Auth/ResetPassword.php index 7ceb0d6..93c40b9 100644 --- a/app/Livewire/Auth/ResetPassword.php +++ b/app/Livewire/Auth/ResetPassword.php @@ -50,7 +50,7 @@ class ResetPassword extends Component // database. Otherwise we will parse the error and return the response. $status = Password::reset( $this->only('email', 'password', 'password_confirmation', 'token'), - function ($user) { + function ($user): void { $user->forceFill([ 'password' => Hash::make($this->password), 'remember_token' => Str::random(60), diff --git a/app/Livewire/Settings/TwoFactor/RecoveryCodes.php b/app/Livewire/Settings/TwoFactor/RecoveryCodes.php index 7352d80..3736dac 100644 --- a/app/Livewire/Settings/TwoFactor/RecoveryCodes.php +++ b/app/Livewire/Settings/TwoFactor/RecoveryCodes.php @@ -39,7 +39,7 @@ class RecoveryCodes extends Component if ($user->hasEnabledTwoFactorAuthentication() && $user->two_factor_recovery_codes) { try { - $this->recoveryCodes = json_decode(decrypt($user->two_factor_recovery_codes), true); + $this->recoveryCodes = json_decode((string) decrypt($user->two_factor_recovery_codes), true); } catch (Exception) { $this->addError('recoveryCodes', 'Failed to load recovery codes'); diff --git a/app/Providers/Filament/DashPanelProvider.php b/app/Providers/Filament/DashPanelProvider.php index a6a070e..ae70728 100644 --- a/app/Providers/Filament/DashPanelProvider.php +++ b/app/Providers/Filament/DashPanelProvider.php @@ -60,21 +60,16 @@ class DashPanelProvider extends PanelProvider ->plugins([ FilamentLoggerPlugin::make(), FilamentLogViewerPlugin::make(), - FilamentMailsPlugin::make()->canManageMails(function () { + FilamentMailsPlugin::make()->canManageMails(function (): bool { $user = Auth::user(); // Allow access for users with specific roles if ($user->hasRole('admin')) { return true; } - // Allow access for users with specific permissions - if ($user->hasPermissionTo('manage mails')) { - return true; - } - // Restrict access for all other users - return false; + return (bool) $user->hasPermissionTo('manage mails'); }), ]) ->routes(fn () => FilamentMails::routes()); diff --git a/app/Providers/FortifyServiceProvider.php b/app/Providers/FortifyServiceProvider.php index b99dcc7..2a893b0 100644 --- a/app/Providers/FortifyServiceProvider.php +++ b/app/Providers/FortifyServiceProvider.php @@ -23,11 +23,9 @@ class FortifyServiceProvider extends ServiceProvider */ public function boot(): void { - Fortify::twoFactorChallengeView(fn () => view('livewire.auth.two-factor-challenge')); - Fortify::confirmPasswordView(fn () => view('livewire.auth.confirm-password')); + Fortify::twoFactorChallengeView(fn (): \Illuminate\Contracts\View\View|\Illuminate\Contracts\View\Factory => view('livewire.auth.two-factor-challenge')); + Fortify::confirmPasswordView(fn (): \Illuminate\Contracts\View\View|\Illuminate\Contracts\View\Factory => view('livewire.auth.confirm-password')); - RateLimiter::for('two-factor', function (Request $request) { - return Limit::perMinute(5)->by($request->session()->get('login.id')); - }); + RateLimiter::for('two-factor', fn(Request $request) => Limit::perMinute(5)->by($request->session()->get('login.id'))); } } diff --git a/config/app.php b/config/app.php index 324b513..423eed5 100644 --- a/config/app.php +++ b/config/app.php @@ -101,7 +101,7 @@ return [ 'previous_keys' => [ ...array_filter( - explode(',', env('APP_PREVIOUS_KEYS', '')) + explode(',', (string) env('APP_PREVIOUS_KEYS', '')) ), ], diff --git a/config/filament-log-viewer.php b/config/filament-log-viewer.php index 1480dfa..a39f11f 100644 --- a/config/filament-log-viewer.php +++ b/config/filament-log-viewer.php @@ -44,7 +44,7 @@ return [ 'pattern' => [ 'prefix' => 'laravel-', - 'date' => '[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]', + 'date' => 'dddd-dd-dd', 'extension' => '.log' ], diff --git a/config/logging.php b/config/logging.php index 8d94292..53b493f 100644 --- a/config/logging.php +++ b/config/logging.php @@ -54,7 +54,7 @@ return [ 'stack' => [ 'driver' => 'stack', - 'channels' => explode(',', env('LOG_STACK', 'single')), + 'channels' => explode(',', (string) env('LOG_STACK', 'single')), 'ignore_exceptions' => false, ], diff --git a/config/mail.php b/config/mail.php index 756305b..692b2a0 100644 --- a/config/mail.php +++ b/config/mail.php @@ -46,7 +46,7 @@ return [ 'username' => env('MAIL_USERNAME'), 'password' => env('MAIL_PASSWORD'), 'timeout' => null, - 'local_domain' => env('MAIL_EHLO_DOMAIN', parse_url(env('APP_URL', 'http://localhost'), PHP_URL_HOST)), + 'local_domain' => env('MAIL_EHLO_DOMAIN', parse_url((string) env('APP_URL', 'http://localhost'), PHP_URL_HOST)), ], 'ses' => [ diff --git a/rector.php b/rector.php index dd711c1..82f0630 100644 --- a/rector.php +++ b/rector.php @@ -8,8 +8,6 @@ use Rector\Php83\Rector\ClassMethod\AddOverrideAttributeToOverriddenMethodsRecto return RectorConfig::configure() ->withPaths([ __DIR__ . '/app', - __DIR__ . '/bootstrap', - __DIR__ . '/resources', __DIR__ . '/routes', __DIR__ . '/config', __DIR__ . '/tests', diff --git a/routes/auth.php b/routes/auth.php index 3d7863a..7cc8a14 100644 --- a/routes/auth.php +++ b/routes/auth.php @@ -9,14 +9,14 @@ use App\Livewire\Auth\ResetPassword; use App\Livewire\Auth\VerifyEmail; use Illuminate\Support\Facades\Route; -Route::middleware('guest')->group(function () { +Route::middleware('guest')->group(function (): void { Route::get('login', Login::class)->name('login'); Route::get('register', Register::class)->name('register'); Route::get('forgot-password', ForgotPassword::class)->name('password.request'); Route::get('reset-password/{token}', ResetPassword::class)->name('password.reset'); }); -Route::middleware('auth')->group(function () { +Route::middleware('auth')->group(function (): void { Route::get('verify-email', VerifyEmail::class) ->name('verification.notice'); diff --git a/routes/console.php b/routes/console.php index 3c9adf1..fa9463c 100644 --- a/routes/console.php +++ b/routes/console.php @@ -3,6 +3,6 @@ use Illuminate\Foundation\Inspiring; use Illuminate\Support\Facades\Artisan; -Artisan::command('inspire', function () { +Artisan::command('inspire', function (): void { $this->comment(Inspiring::quote()); })->purpose('Display an inspiring quote'); diff --git a/routes/web.php b/routes/web.php index 6c0f8cf..d357b6d 100644 --- a/routes/web.php +++ b/routes/web.php @@ -7,15 +7,13 @@ use App\Livewire\Settings\TwoFactor; use Illuminate\Support\Facades\Route; use Laravel\Fortify\Features; -Route::get('/', function () { - return view('welcome'); -})->name('home'); +Route::get('/', fn(): \Illuminate\Contracts\View\View|\Illuminate\Contracts\View\Factory => view('welcome'))->name('home'); Route::view('dashboard', 'dashboard') ->middleware(['auth', 'verified']) ->name('dashboard'); -Route::middleware(['auth'])->group(function () { +Route::middleware(['auth'])->group(function (): void { Route::redirect('settings', 'settings/profile'); Route::get('settings/profile', Profile::class)->name('settings.profile'); diff --git a/tests/Feature/Auth/AuthenticationTest.php b/tests/Feature/Auth/AuthenticationTest.php index 8d04bb3..9a2ff76 100644 --- a/tests/Feature/Auth/AuthenticationTest.php +++ b/tests/Feature/Auth/AuthenticationTest.php @@ -5,13 +5,13 @@ use App\Models\User; use Laravel\Fortify\Features; use Livewire\Livewire; -test('login screen can be rendered', function () { +test('login screen can be rendered', function (): void { $response = $this->get('/login'); $response->assertStatus(200); }); -test('users can authenticate using the login screen', function () { +test('users can authenticate using the login screen', function (): void { $user = User::factory()->create(); $response = Livewire::test(Login::class) @@ -26,7 +26,7 @@ test('users can authenticate using the login screen', function () { $this->assertAuthenticated(); }); -test('users can not authenticate with invalid password', function () { +test('users can not authenticate with invalid password', function (): void { $user = User::factory()->create(); $response = Livewire::test(Login::class) @@ -39,7 +39,7 @@ test('users can not authenticate with invalid password', function () { $this->assertGuest(); }); -test('users with two factor enabled are redirected to two factor challenge', function () { +test('users with two factor enabled are redirected to two factor challenge', function (): void { if (! Features::canManageTwoFactorAuthentication()) { $this->markTestSkipped('Two-factor authentication is not enabled.'); } @@ -67,7 +67,7 @@ test('users with two factor enabled are redirected to two factor challenge', fun $this->assertGuest(); }); -test('users can logout', function () { +test('users can logout', function (): void { $user = User::factory()->create(); $response = $this->actingAs($user)->post('/logout'); diff --git a/tests/Feature/Auth/EmailVerificationTest.php b/tests/Feature/Auth/EmailVerificationTest.php index a2294e8..b4cf1d6 100644 --- a/tests/Feature/Auth/EmailVerificationTest.php +++ b/tests/Feature/Auth/EmailVerificationTest.php @@ -5,7 +5,7 @@ use Illuminate\Auth\Events\Verified; use Illuminate\Support\Facades\Event; use Illuminate\Support\Facades\URL; -test('email verification screen can be rendered', function () { +test('email verification screen can be rendered', function (): void { $user = User::factory()->unverified()->create(); $response = $this->actingAs($user)->get('/verify-email'); @@ -13,7 +13,7 @@ test('email verification screen can be rendered', function () { $response->assertStatus(200); }); -test('email can be verified', function () { +test('email can be verified', function (): void { $user = User::factory()->unverified()->create(); Event::fake(); @@ -21,7 +21,7 @@ test('email can be verified', function () { $verificationUrl = URL::temporarySignedRoute( 'verification.verify', now()->addMinutes(60), - ['id' => $user->id, 'hash' => sha1($user->email)] + ['id' => $user->id, 'hash' => sha1((string) $user->email)] ); $response = $this->actingAs($user)->get($verificationUrl); @@ -32,7 +32,7 @@ test('email can be verified', function () { $response->assertRedirect(route('dashboard', absolute: false).'?verified=1'); }); -test('email is not verified with invalid hash', function () { +test('email is not verified with invalid hash', function (): void { $user = User::factory()->unverified()->create(); $verificationUrl = URL::temporarySignedRoute( diff --git a/tests/Feature/Auth/PasswordConfirmationTest.php b/tests/Feature/Auth/PasswordConfirmationTest.php index de14aae..f694581 100644 --- a/tests/Feature/Auth/PasswordConfirmationTest.php +++ b/tests/Feature/Auth/PasswordConfirmationTest.php @@ -2,7 +2,7 @@ use App\Models\User; -test('confirm password screen can be rendered', function () { +test('confirm password screen can be rendered', function (): void { $user = User::factory()->create(); $response = $this->actingAs($user)->get(route('password.confirm')); diff --git a/tests/Feature/Auth/PasswordResetTest.php b/tests/Feature/Auth/PasswordResetTest.php index 45905ad..be78278 100644 --- a/tests/Feature/Auth/PasswordResetTest.php +++ b/tests/Feature/Auth/PasswordResetTest.php @@ -7,13 +7,13 @@ use Illuminate\Auth\Notifications\ResetPassword as ResetPasswordNotification; use Illuminate\Support\Facades\Notification; use Livewire\Livewire; -test('reset password link screen can be rendered', function () { +test('reset password link screen can be rendered', function (): void { $response = $this->get('/forgot-password'); $response->assertStatus(200); }); -test('reset password link can be requested', function () { +test('reset password link can be requested', function (): void { Notification::fake(); $user = User::factory()->create(); @@ -25,7 +25,7 @@ test('reset password link can be requested', function () { Notification::assertSentTo($user, ResetPasswordNotification::class); }); -test('reset password screen can be rendered', function () { +test('reset password screen can be rendered', function (): void { Notification::fake(); $user = User::factory()->create(); @@ -34,7 +34,7 @@ test('reset password screen can be rendered', function () { ->set('email', $user->email) ->call('sendPasswordResetLink'); - Notification::assertSentTo($user, ResetPasswordNotification::class, function ($notification) { + Notification::assertSentTo($user, ResetPasswordNotification::class, function ($notification): true { $response = $this->get('/reset-password/'.$notification->token); $response->assertStatus(200); @@ -43,7 +43,7 @@ test('reset password screen can be rendered', function () { }); }); -test('password can be reset with valid token', function () { +test('password can be reset with valid token', function (): void { Notification::fake(); $user = User::factory()->create(); @@ -52,7 +52,7 @@ test('password can be reset with valid token', function () { ->set('email', $user->email) ->call('sendPasswordResetLink'); - Notification::assertSentTo($user, ResetPasswordNotification::class, function ($notification) use ($user) { + Notification::assertSentTo($user, ResetPasswordNotification::class, function ($notification) use ($user): true { $response = Livewire::test(ResetPassword::class, ['token' => $notification->token]) ->set('email', $user->email) ->set('password', 'password') diff --git a/tests/Feature/Auth/RegistrationTest.php b/tests/Feature/Auth/RegistrationTest.php index d3c1819..ba2cb20 100644 --- a/tests/Feature/Auth/RegistrationTest.php +++ b/tests/Feature/Auth/RegistrationTest.php @@ -3,13 +3,13 @@ use App\Livewire\Auth\Register; use Livewire\Livewire; -test('registration screen can be rendered', function () { +test('registration screen can be rendered', function (): void { $response = $this->get('/register'); $response->assertStatus(200); }); -test('new users can register', function () { +test('new users can register', function (): void { $response = Livewire::test(Register::class) ->set('name', 'Test User') ->set('email', 'test@example.com') diff --git a/tests/Feature/Auth/TwoFactorChallengeTest.php b/tests/Feature/Auth/TwoFactorChallengeTest.php index 236ebe4..c3b3c88 100644 --- a/tests/Feature/Auth/TwoFactorChallengeTest.php +++ b/tests/Feature/Auth/TwoFactorChallengeTest.php @@ -4,7 +4,7 @@ use App\Models\User; use Laravel\Fortify\Features; use Livewire\Livewire; -test('two factor challenge redirects to login when not authenticated', function () { +test('two factor challenge redirects to login when not authenticated', function (): void { if (! Features::canManageTwoFactorAuthentication()) { $this->markTestSkipped('Two-factor authentication is not enabled.'); } @@ -14,7 +14,7 @@ test('two factor challenge redirects to login when not authenticated', function $response->assertRedirect(route('login')); }); -test('two factor challenge can be rendered', function () { +test('two factor challenge can be rendered', function (): void { if (! Features::canManageTwoFactorAuthentication()) { $this->markTestSkipped('Two-factor authentication is not enabled.'); } diff --git a/tests/Feature/DashboardTest.php b/tests/Feature/DashboardTest.php index 1eb23b5..db81733 100644 --- a/tests/Feature/DashboardTest.php +++ b/tests/Feature/DashboardTest.php @@ -2,11 +2,11 @@ use App\Models\User; -test('guests are redirected to the login page', function () { +test('guests are redirected to the login page', function (): void { $this->get('/dashboard')->assertRedirect('/login'); }); -test('authenticated users can visit the dashboard', function () { +test('authenticated users can visit the dashboard', function (): void { $this->actingAs($user = User::factory()->create()); $this->get('/dashboard')->assertStatus(200); diff --git a/tests/Feature/ExampleTest.php b/tests/Feature/ExampleTest.php index b63b781..1133ac0 100644 --- a/tests/Feature/ExampleTest.php +++ b/tests/Feature/ExampleTest.php @@ -1,6 +1,6 @@ get('/'); $response->assertStatus(200); diff --git a/tests/Feature/Settings/PasswordUpdateTest.php b/tests/Feature/Settings/PasswordUpdateTest.php index 8b07a80..e2701de 100644 --- a/tests/Feature/Settings/PasswordUpdateTest.php +++ b/tests/Feature/Settings/PasswordUpdateTest.php @@ -5,7 +5,7 @@ use App\Models\User; use Illuminate\Support\Facades\Hash; use Livewire\Livewire; -test('password can be updated', function () { +test('password can be updated', function (): void { $user = User::factory()->create([ 'password' => Hash::make('password'), ]); @@ -23,7 +23,7 @@ test('password can be updated', function () { expect(Hash::check('new-password', $user->refresh()->password))->toBeTrue(); }); -test('correct password must be provided to update password', function () { +test('correct password must be provided to update password', function (): void { $user = User::factory()->create([ 'password' => Hash::make('password'), ]); diff --git a/tests/Feature/Settings/ProfileUpdateTest.php b/tests/Feature/Settings/ProfileUpdateTest.php index 6d30fee..d02d934 100644 --- a/tests/Feature/Settings/ProfileUpdateTest.php +++ b/tests/Feature/Settings/ProfileUpdateTest.php @@ -4,13 +4,13 @@ use App\Livewire\Settings\Profile; use App\Models\User; use Livewire\Livewire; -test('profile page is displayed', function () { +test('profile page is displayed', function (): void { $this->actingAs($user = User::factory()->create()); $this->get('/settings/profile')->assertOk(); }); -test('profile information can be updated', function () { +test('profile information can be updated', function (): void { $user = User::factory()->create(); $this->actingAs($user); @@ -29,7 +29,7 @@ test('profile information can be updated', function () { expect($user->email_verified_at)->toBeNull(); }); -test('email verification status is unchanged when email address is unchanged', function () { +test('email verification status is unchanged when email address is unchanged', function (): void { $user = User::factory()->create(); $this->actingAs($user); @@ -44,7 +44,7 @@ test('email verification status is unchanged when email address is unchanged', f expect($user->refresh()->email_verified_at)->not->toBeNull(); }); -test('user can delete their account', function () { +test('user can delete their account', function (): void { $user = User::factory()->create(); $this->actingAs($user); @@ -61,7 +61,7 @@ test('user can delete their account', function () { expect(auth()->check())->toBeFalse(); }); -test('correct password must be provided to delete account', function () { +test('correct password must be provided to delete account', function (): void { $user = User::factory()->create(); $this->actingAs($user); diff --git a/tests/Feature/Settings/TwoFactorAuthenticationTest.php b/tests/Feature/Settings/TwoFactorAuthenticationTest.php index 90c44ad..3e7c1b7 100644 --- a/tests/Feature/Settings/TwoFactorAuthenticationTest.php +++ b/tests/Feature/Settings/TwoFactorAuthenticationTest.php @@ -4,7 +4,7 @@ use App\Models\User; use Laravel\Fortify\Features; use Livewire\Livewire; -beforeEach(function () { +beforeEach(function (): void { if (! Features::canManageTwoFactorAuthentication()) { $this->markTestSkipped('Two-factor authentication is not enabled.'); } @@ -15,7 +15,7 @@ beforeEach(function () { ]); }); -test('two factor settings page can be rendered', function () { +test('two factor settings page can be rendered', function (): void { $user = User::factory()->create(); $this->actingAs($user) @@ -26,7 +26,7 @@ test('two factor settings page can be rendered', function () { ->assertSee('Disabled'); }); -test('two factor settings page requires password confirmation when enabled', function () { +test('two factor settings page requires password confirmation when enabled', function (): void { $user = User::factory()->create(); $response = $this->actingAs($user) @@ -35,7 +35,7 @@ test('two factor settings page requires password confirmation when enabled', fun $response->assertRedirect(route('password.confirm')); }); -test('two factor settings page returns forbidden response when two factor is disabled', function () { +test('two factor settings page returns forbidden response when two factor is disabled', function (): void { config(['fortify.features' => []]); $user = User::factory()->create(); @@ -47,7 +47,7 @@ test('two factor settings page returns forbidden response when two factor is dis $response->assertForbidden(); }); -test('two factor authentication disabled when confirmation abandoned between requests', function () { +test('two factor authentication disabled when confirmation abandoned between requests', function (): void { $user = User::factory()->create(); $user->forceFill([ diff --git a/tests/Pest.php b/tests/Pest.php index 40d096b..8162633 100644 --- a/tests/Pest.php +++ b/tests/Pest.php @@ -26,9 +26,7 @@ pest()->extend(Tests\TestCase::class) | */ -expect()->extend('toBeOne', function () { - return $this->toBe(1); -}); +expect()->extend('toBeOne', fn() => $this->toBe(1)); /* |-------------------------------------------------------------------------- @@ -41,7 +39,7 @@ expect()->extend('toBeOne', function () { | */ -function something() +function something(): void { // .. } diff --git a/tests/Unit/ExampleTest.php b/tests/Unit/ExampleTest.php index 27f3f87..cfa2563 100644 --- a/tests/Unit/ExampleTest.php +++ b/tests/Unit/ExampleTest.php @@ -1,5 +1,5 @@ toBeTrue(); }); \ No newline at end of file