Shift with red gradient lettering
Loading navigation...

Adopt Laravel type hints

Premium
Laravel

Starting with Laravel 10, all code included within a default Laravel application now has PHP type hints.

Before

<?php
 
namespace App\Http\Middleware;
 
use App\Providers\RouteServiceProvider;
use Closure;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;
 
class RedirectIfAuthenticated
{
public function handle(Request $request, Closure $next, ...$guards)
{
// ...
}
}

After

<?php
 
namespace App\Http\Middleware;
 
use App\Providers\RouteServiceProvider;
use Closure;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;
use Symfony\Component\HttpFoundation\Response;
 
class RedirectIfAuthenticated
{
public function handle(Request $request, Closure $next, string ...$guards): Response
{
// ...
}
}

← Back to the Workbench Tasks