for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace App\Http\Middleware;
use Auth;
use Closure;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Log;
use Illuminate\Support\Facades\Route;
class CheckCurrentUser
{
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @return mixed
*/
public function handle($request, Closure $next)
if (! $request->user()) {
abort(403, 'Unauthorized action.');
}
return $next($request);
public function terminate($request, $response)
$response
If this is a false-positive, you can also ignore this issue in your code via the ignore-unused annotation
ignore-unused
public function terminate($request, /** @scrutinizer ignore-unused */ $response)
This check looks for parameters that have been defined for a function or method, but which are not used in the method body.
$request
public function terminate(/** @scrutinizer ignore-unused */ $request, $response)
$user = Auth::user();
$currentRoute = Route::currentRouteName();
Log::info('CheckCurrentUser middlware was used: '.$currentRoute.'. ', [$user]);
This check looks for parameters that have been defined for a function or method, but which are not used in the method body.