22
33namespace BookStack \Exceptions ;
44
5- use Exception ;
65use Illuminate \Auth \AuthenticationException ;
76use Illuminate \Database \Eloquent \ModelNotFoundException ;
87use Illuminate \Foundation \Exceptions \Handler as ExceptionHandler ;
1211use Illuminate \Http \Response ;
1312use Illuminate \Validation \ValidationException ;
1413use Symfony \Component \ErrorHandler \Error \FatalError ;
14+ use Symfony \Component \HttpFoundation \Response as SymfonyResponse ;
1515use Symfony \Component \HttpKernel \Exception \HttpExceptionInterface ;
1616use Throwable ;
1717
@@ -20,7 +20,7 @@ class Handler extends ExceptionHandler
2020 /**
2121 * A list of the exception types that are not reported.
2222 *
23- * @var array<int, class-string<\ Throwable>>
23+ * @var array<int, class-string<Throwable>>
2424 */
2525 protected $ dontReport = [
2626 NotFoundException::class,
@@ -50,11 +50,11 @@ class Handler extends ExceptionHandler
5050 /**
5151 * Report or log an exception.
5252 *
53- * @param \Throwable $exception
54- *
55- * @throws \Throwable
53+ * @param Throwable $exception
5654 *
5755 * @return void
56+ *@throws Throwable
57+ *
5858 */
5959 public function report (Throwable $ exception )
6060 {
@@ -64,12 +64,9 @@ public function report(Throwable $exception)
6464 /**
6565 * Render an exception into an HTTP response.
6666 *
67- * @param \Illuminate\Http\Request $request
68- * @param Exception $e
69- *
70- * @return \Illuminate\Http\Response
67+ * @param Request $request
7168 */
72- public function render ($ request , Throwable $ e )
69+ public function render ($ request , Throwable $ e ): SymfonyResponse
7370 {
7471 if ($ e instanceof FatalError && str_contains ($ e ->getMessage (), 'bytes exhausted (tried to allocate ' ) && $ this ->onOutOfMemory ) {
7572 $ response = call_user_func ($ this ->onOutOfMemory );
@@ -152,12 +149,9 @@ protected function renderApiException(Throwable $e): JsonResponse
152149 /**
153150 * Convert an authentication exception into an unauthenticated response.
154151 *
155- * @param \Illuminate\Http\Request $request
156- * @param \Illuminate\Auth\AuthenticationException $exception
157- *
158- * @return \Illuminate\Http\Response
152+ * @param Request $request
159153 */
160- protected function unauthenticated ($ request , AuthenticationException $ exception )
154+ protected function unauthenticated ($ request , AuthenticationException $ exception ): SymfonyResponse
161155 {
162156 if ($ request ->expectsJson ()) {
163157 return response ()->json (['error ' => 'Unauthenticated. ' ], 401 );
@@ -169,12 +163,9 @@ protected function unauthenticated($request, AuthenticationException $exception)
169163 /**
170164 * Convert a validation exception into a JSON response.
171165 *
172- * @param \Illuminate\Http\Request $request
173- * @param \Illuminate\Validation\ValidationException $exception
174- *
175- * @return \Illuminate\Http\JsonResponse
166+ * @param Request $request
176167 */
177- protected function invalidJson ($ request , ValidationException $ exception )
168+ protected function invalidJson ($ request , ValidationException $ exception ): JsonResponse
178169 {
179170 return response ()->json ($ exception ->errors (), $ exception ->status );
180171 }
0 commit comments