2020use Symfony \Component \HttpKernel \Exception \NotFoundHttpException ;
2121use Symfony \Component \HttpKernel \KernelEvents ;
2222use Symfony \Component \Security \Core \Authentication \Token \Storage \TokenStorageInterface ;
23+ use Throwable ;
2324use Traversable ;
2425
2526/**
2627 * This Service triggers on the kernel.exception and catches any HTTP 500 error. When an HTTP 500 error is detected,
27- * an e-mail is send to maintainers.
28+ * an e-mail is sent to maintainers.
2829 *
2930 * Pick one of the available implementations, based on your mailer configuration.
3031 *
@@ -77,24 +78,22 @@ public function __construct(TokenStorageInterface $tokenStorage, ConfigurationIn
7778 * while the KernelResponse event is used to determine if the 500 error message is actually displayed to the user.
7879 * This ensures that NotAuthorizedExceptions are not mailed as a 500 error (as a 403 error is presented).
7980 */
80- static protected function getSubscribedEvents ()
81+ static protected function getSubscribedEvents (): array
8182 {
82- return array (
83- KernelEvents::EXCEPTION => array ( array ( 'onKernelException ' , 0 )) ,
84- KernelEvents::RESPONSE => array ( array ( 'onKernelResponse ' , 0 )) ,
85- ) ;
83+ return [
84+ KernelEvents::EXCEPTION => [[ 'onKernelException ' , 0 ]] ,
85+ KernelEvents::RESPONSE => [[ 'onKernelResponse ' , 0 ]] ,
86+ ] ;
8687 }
8788
8889 /**
89- * This function will create create the backtrace and save it with an random
90+ * This function will create the backtrace and save it with a random
9091 * name in /web/uploads/exceptionBacktrace/ and save the name in the session so
9192 * in the html status exception handler load the backtrace and send it in an email.
9293 *
93- * @param ExceptionEvent $event
94- *
9594 * @throws Exception
9695 */
97- public function onKernelException (ExceptionEvent $ event )
96+ public function onKernelException (ExceptionEvent $ event ): void
9897 {
9998 // Skip some exception types directly
10099 $ exception = $ event ->getThrowable ();
@@ -172,12 +171,8 @@ public function onKernelException(ExceptionEvent $event)
172171
173172 /**
174173 * This function builds a backtrace
175- *
176- * @param ExceptionEvent $event
177- *
178- * @return string
179174 */
180- protected function buildBacktrace (ExceptionEvent $ event )
175+ protected function buildBacktrace (ExceptionEvent $ event ): string
181176 {
182177 $ user = $ this ->configuration ->getUserInformation ($ this ->tokenStorage ->getToken ());
183178
@@ -196,11 +191,9 @@ protected function buildBacktrace(ExceptionEvent $event)
196191 * This function handles the Kernel exception response. When the response contains an http 500 error, it is tried to
197192 * get the backtrace from the server (via the file name stored in the session) and mail this to the maintainers
198193 *
199- * @param ResponseEvent $responseObject
200- *
201194 * @throws Exception
202195 */
203- public function onKernelResponse (ResponseEvent $ responseObject )
196+ public function onKernelResponse (ResponseEvent $ responseObject ): void
204197 {
205198 $ response = $ responseObject ->getResponse ();
206199 $ request = $ responseObject ->getRequest ();
@@ -318,25 +311,15 @@ public function onKernelResponse(ResponseEvent $responseObject)
318311 }
319312 }
320313
321- /**
322- * @param $url
323- * @param $exceptionMessage
324- *
325- * @return string
326- */
327- protected function generateHash ($ url , $ exceptionMessage )
314+ protected function generateHash (string $ url , string $ exceptionMessage ): string
328315 {
329316 return md5 ($ url . $ exceptionMessage );
330317 }
331318
332319 /**
333320 * Removes a variable from the request
334- *
335- * @param Request $request
336- * @param string $parameterBin
337- * @param string $variable
338321 */
339- protected function removeVar (Request $ request , $ parameterBin , $ variable )
322+ protected function removeVar (Request $ request , string $ parameterBin , string $ variable ): void
340323 {
341324 if ($ request ->$ parameterBin ->has ($ variable )) {
342325 $ request ->$ parameterBin ->set ($ variable , '**REMOVED** ' );
@@ -345,12 +328,8 @@ protected function removeVar(Request $request, $parameterBin, $variable)
345328
346329 /**
347330 * Removes a variables from the request
348- *
349- * @param Request $request
350- * @param string $parameterBin
351- * @param array $variables
352331 */
353- protected function removeVars (Request $ request , $ parameterBin , array $ variables )
332+ protected function removeVars (Request $ request , string $ parameterBin , array $ variables ): void
354333 {
355334 foreach ($ variables as $ variable ) {
356335 $ this ->removeVar ($ request , $ parameterBin , $ variable );
@@ -363,12 +342,8 @@ protected function removeVars(Request $request, $parameterBin, array $variables)
363342
364343 /**
365344 * Returns the request as a string.
366- *
367- * @param Request $request
368- *
369- * @return string The request
370345 */
371- protected function getRequestString (Request $ request )
346+ protected function getRequestString (Request $ request ): string
372347 {
373348 $ string =
374349 sprintf ('%s %s %s ' , $ request ->getMethod (), $ request ->getRequestUri (), $ request ->server ->get ('SERVER_PROTOCOL ' )) . "\r\n\r\nRequest headers: \r\n" .
@@ -389,14 +364,8 @@ protected function getRequestString(Request $request)
389364
390365 /**
391366 * Convert an array to string
392- *
393- * @param $array
394- * @param int $currentDepth
395- * @param int $maxDepth
396- *
397- * @return string
398367 */
399- protected function arrayToString ($ array , $ currentDepth = 0 , $ maxDepth = 3 )
368+ protected function arrayToString (array $ array , int $ currentDepth = 0 , int $ maxDepth = 3 ): string
400369 {
401370 if ($ currentDepth >= $ maxDepth ) {
402371 return '**Maximum recursion level reached** ' ;
@@ -418,25 +387,11 @@ protected function arrayToString($array, $currentDepth = 0, $maxDepth = 3)
418387 }
419388
420389 /**
421- * @param $uploadException
422- * @param BacktraceLogFile $backtrace
423- *
424390 * @throws Exception
425391 */
426- abstract protected function sendExceptionHandledFailedMessage ($ uploadException , BacktraceLogFile $ backtrace ): void ;
392+ abstract protected function sendExceptionHandledFailedMessage (Throwable $ uploadException , BacktraceLogFile $ backtrace ): void ;
427393
428394 /**
429- * @param SessionInterface|null $session
430- * @param string $requestUri
431- * @param string $baseUrl
432- * @param string $method
433- * @param string $requestString
434- * @param array $responseString
435- * @param string $backtrace
436- * @param string $serverVariablesString
437- * @param string $globalVariablesString
438- * @param string $extension
439- *
440395 * @throws Exception
441396 */
442397 abstract protected function sendExceptionMessage (
0 commit comments