These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | |||
3 | namespace App\Exceptions; |
||
4 | |||
5 | use Exception; |
||
6 | use Illuminate\Auth\Access\AuthorizationException; |
||
7 | use Illuminate\Auth\AuthenticationException; |
||
8 | use Illuminate\Database\Eloquent\ModelNotFoundException; |
||
9 | use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler; |
||
10 | use Illuminate\Foundation\Validation\ValidationException; |
||
11 | use Symfony\Component\HttpKernel\Exception\HttpException; |
||
12 | use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; |
||
13 | |||
14 | class Handler extends ExceptionHandler |
||
15 | { |
||
16 | /** |
||
17 | * A list of the exception types that should not be reported. |
||
18 | * |
||
19 | * @var array |
||
20 | */ |
||
21 | protected $dontReport = [ |
||
22 | AuthorizationException::class, |
||
23 | HttpException::class, |
||
24 | ModelNotFoundException::class, |
||
25 | ValidationException::class, |
||
26 | ]; |
||
27 | |||
28 | /** |
||
29 | * Report or log an exception. |
||
30 | * |
||
31 | * This is a great spot to send exceptions to Sentry, Bugsnag, etc. |
||
32 | * |
||
33 | * @param \Exception $e |
||
34 | */ |
||
35 | public function report(Exception $e) |
||
36 | { |
||
37 | parent::report($e); |
||
38 | } |
||
39 | |||
40 | /** |
||
41 | * Render an exception into an HTTP response. |
||
42 | * |
||
43 | * @param \Illuminate\Http\Request $request |
||
44 | * @param \Exception $e |
||
45 | * |
||
46 | * @return \Illuminate\Http\Response |
||
47 | */ |
||
48 | public function render($request, Exception $e) |
||
49 | { |
||
50 | if ($e instanceof ModelNotFoundException) { |
||
51 | $e = new NotFoundHttpException($e->getMessage(), $e); |
||
52 | } |
||
53 | |||
54 | return parent::render($request, $e); |
||
55 | } |
||
56 | |||
57 | /** |
||
58 | * Convert an authentication exception into an unauthenticated response. |
||
59 | * |
||
60 | * @param \Illuminate\Http\Request $request |
||
61 | * @param \Illuminate\Auth\AuthenticationException $exception |
||
62 | * |
||
63 | * @return \Illuminate\Http\Response |
||
64 | */ |
||
65 | protected function unauthenticated($request, AuthenticationException $exception) |
||
0 ignored issues
–
show
|
|||
66 | { |
||
67 | if ($request->expectsJson()) { |
||
68 | return response()->json(['error' => 'Unauthenticated.'], 401); |
||
69 | } |
||
70 | |||
71 | return redirect()->guest('login'); |
||
72 | } |
||
73 | } |
||
74 |
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.