@@ -30,11 +30,11 @@ discard block |
||
| 30 | 30 | * @param int $bitmask |
| 31 | 31 | */ |
| 32 | 32 | public static function enableExceptionsForErrors(int $bitmask = E_ALL): void { |
| 33 | - set_error_handler(function ($level, $message, $file, $line) use ($bitmask) { |
|
| 34 | - if(0 === error_reporting()) { |
|
| 33 | + set_error_handler(function($level, $message, $file, $line) use ($bitmask) { |
|
| 34 | + if (0 === error_reporting()) { |
|
| 35 | 35 | return false; |
| 36 | 36 | } |
| 37 | - if(($bitmask & $level) !== 0) { |
|
| 37 | + if (($bitmask & $level) !== 0) { |
|
| 38 | 38 | throw new ErrorException($message, 0, $level, $file, $line); |
| 39 | 39 | } |
| 40 | 40 | |
@@ -47,11 +47,11 @@ discard block |
||
| 47 | 47 | * @param string $logLevel PSR-3 Log-Level |
| 48 | 48 | */ |
| 49 | 49 | public static function registerAssertionHandler(LoggerInterface $logger, string $logLevel): void { |
| 50 | - if(self::$assertionLogger === null) { |
|
| 50 | + if (self::$assertionLogger === null) { |
|
| 51 | 51 | self::$assertionLogger = new LoggerCollection(); |
| 52 | 52 | assert_options(ASSERT_ACTIVE, true); |
| 53 | 53 | assert_options(ASSERT_WARNING, false); |
| 54 | - assert_options(ASSERT_CALLBACK, static function (string $file, int $line, ?string $code, ?string $description = null) use ($logLevel): void { |
|
| 54 | + assert_options(ASSERT_CALLBACK, static function(string $file, int $line, ?string $code, ?string $description = null) use ($logLevel) : void { |
|
| 55 | 55 | self::$assertionLogger?->log($logLevel, (string) $description, [ |
| 56 | 56 | 'file' => $file, |
| 57 | 57 | 'line' => $line, |
@@ -65,11 +65,11 @@ discard block |
||
| 65 | 65 | * @param LoggerInterface $logger |
| 66 | 66 | */ |
| 67 | 67 | public static function registerFatalErrorHandler(LoggerInterface $logger): void { |
| 68 | - if(self::$fatalLogger === null) { |
|
| 68 | + if (self::$fatalLogger === null) { |
|
| 69 | 69 | self::$fatalLogger = new LoggerCollection(); |
| 70 | - register_shutdown_function(function (): void { |
|
| 70 | + register_shutdown_function(function(): void { |
|
| 71 | 71 | $error = error_get_last(); |
| 72 | - if($error !== null && in_array($error['type'], self::FATAL_LEVELS, true)) { |
|
| 72 | + if ($error !== null && in_array($error['type'], self::FATAL_LEVELS, true)) { |
|
| 73 | 73 | $fl = new LogLevelRangeFilter(self::$fatalLogger ?? new LoggerCollection(), LogLevel::ERROR); |
| 74 | 74 | $fl->log(LogLevel::ALERT, $error['message'], $error); |
| 75 | 75 | } |
@@ -79,14 +79,14 @@ discard block |
||
| 79 | 79 | } |
| 80 | 80 | |
| 81 | 81 | public static function registerExceptionHandler(LoggerInterface $logger): void { |
| 82 | - if(self::$exceptionLogger === null) { |
|
| 82 | + if (self::$exceptionLogger === null) { |
|
| 83 | 83 | self::$exceptionLogger = new LoggerCollection(); |
| 84 | - set_exception_handler(static function (Throwable $exception): void { |
|
| 84 | + set_exception_handler(static function(Throwable $exception): void { |
|
| 85 | 85 | $log = new LogLevelRangeFilter(self::$exceptionLogger ?? new LoggerCollection(), LogLevel::ERROR); |
| 86 | 86 | try { |
| 87 | 87 | $exceptionAsArray = self::getExceptionAsArray($exception, true, true); |
| 88 | 88 | $log->log(LogLevel::CRITICAL, $exception->getMessage(), ['exception' => $exceptionAsArray]); |
| 89 | - } catch(Throwable) { |
|
| 89 | + } catch (Throwable) { |
|
| 90 | 90 | $exceptionAsArray1 = self::getExceptionAsArray($exception, false, false); |
| 91 | 91 | $log->log(LogLevel::CRITICAL, $exception->getMessage(), ['exception' => $exceptionAsArray1]); |
| 92 | 92 | } |
@@ -105,7 +105,7 @@ discard block |
||
| 105 | 105 | * @phpstan-return TExceptionArray|null |
| 106 | 106 | */ |
| 107 | 107 | private static function getExceptionAsArray(?Throwable $exception, bool $previous, bool $withTrace): ?array { |
| 108 | - if($exception === null) { |
|
| 108 | + if ($exception === null) { |
|
| 109 | 109 | return null; |
| 110 | 110 | } |
| 111 | 111 | |