for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace Fouladgar\MobileVerification\Http\Middleware;
use Closure;
use Fouladgar\MobileVerification\Contracts\MustVerifyMobile;
class EnsureMobileIsVerified
{
/**
* Handle an incoming request.
*
* @param $request
* @param Closure $next
* @param null $redirectToRoute
$redirectToRoute
null
* @return mixed|void
*/
public function handle($request, Closure $next, $redirectToRoute = null)
If this is a false-positive, you can also ignore this issue in your code via the ignore-unused annotation
ignore-unused
public function handle($request, Closure $next, /** @scrutinizer ignore-unused */ $redirectToRoute = null)
This check looks for parameters that have been defined for a function or method, but which are not used in the method body.
$user = auth()->user();
if (! $user || ($user instanceof MustVerifyMobile && ! $user->hasVerifiedMobile())) {
return $request->expectsJson()
? abort(403, 'Your mobile number is not verified.')
abort(403, 'Your mobile number is not verified.')
This check looks for function or method calls that always return null and whose return value is used.
class A { function getObject() { return null; } } $a = new A(); if ($a->getObject()) {
The method getObject() can return nothing but null, so it makes no sense to use the return value.
getObject()
The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.
: redirect('/')->withErrors(['mobile' => 'Your mobile number is not verified.']);
}
return $next($request);