@@ -11,11 +11,11 @@ discard block |
||
| 11 | 11 | public static function printException(Exception $e, $messageIntro = '') { |
| 12 | 12 | self::p("%s[%s] %s\n", $messageIntro, get_class($e), $e->getMessage()); |
| 13 | 13 | |
| 14 | - foreach($e->getTrace() as $idx => $station) { |
|
| 14 | + foreach ($e->getTrace() as $idx => $station) { |
|
| 15 | 15 | self::formatStation($idx, $station); |
| 16 | 16 | } |
| 17 | 17 | |
| 18 | - if($e->getPrevious() instanceof Exception) { |
|
| 18 | + if ($e->getPrevious() instanceof Exception) { |
|
| 19 | 19 | self::p(); |
| 20 | 20 | self::printException($e->getPrevious(), 'Previous: '); |
| 21 | 21 | } |
@@ -36,18 +36,18 @@ discard block |
||
| 36 | 36 | ); |
| 37 | 37 | $station = array_merge($defaults, $station); |
| 38 | 38 | self::p("#%- 3s%s:%d\n", $idx, $station['file'] ?: 'unknown', $station['line']); |
| 39 | - if($station['class'] !== null || $station['function'] !== null) { |
|
| 39 | + if ($station['class'] !== null || $station['function'] !== null) { |
|
| 40 | 40 | $params = array(); |
| 41 | - foreach(is_array($station['args']) ? $station['args'] : array() as $argument) { |
|
| 42 | - if(is_array($argument)) { |
|
| 41 | + foreach (is_array($station['args']) ? $station['args'] : array() as $argument) { |
|
| 42 | + if (is_array($argument)) { |
|
| 43 | 43 | $params[] = sprintf('array%d', count($argument)); |
| 44 | - } elseif(is_object($argument)) { |
|
| 44 | + } elseif (is_object($argument)) { |
|
| 45 | 45 | $params[] = sprintf('%s', get_class($argument)); |
| 46 | 46 | } else { |
| 47 | 47 | $params[] = gettype($argument); |
| 48 | 48 | } |
| 49 | 49 | } |
| 50 | - if(strpos($station['function'], '{closure}') !== false && $station['class'] !== null) { |
|
| 50 | + if (strpos($station['function'], '{closure}') !== false && $station['class'] !== null) { |
|
| 51 | 51 | $station['function'] = '{closure}'; |
| 52 | 52 | } |
| 53 | 53 | self::p(" %s%s%s%s%s%s\n", $station['class'], $station['type'], $station['function'], "(", join(', ', $params), ")"); |
@@ -30,15 +30,15 @@ discard block |
||
| 30 | 30 | * @param int|null $bitmask |
| 31 | 31 | */ |
| 32 | 32 | public static function enableExceptionsForErrors($bitmask = null) { |
| 33 | - set_error_handler(function ($level, $message, $file, $line) use ($bitmask) { |
|
| 33 | + set_error_handler(function($level, $message, $file, $line) use ($bitmask) { |
|
| 34 | 34 | // PHP-7 fix: What once was an E_STRICT is now an E_WARNING: |
| 35 | - if(preg_match('/^Declaration of .*? should be compatible with/', $message)) { |
|
| 35 | + if (preg_match('/^Declaration of .*? should be compatible with/', $message)) { |
|
| 36 | 36 | $level = E_STRICT; |
| 37 | 37 | } |
| 38 | 38 | if (0 === error_reporting()) { |
| 39 | 39 | return false; |
| 40 | 40 | } |
| 41 | - if($bitmask & $level) { |
|
| 41 | + if ($bitmask & $level) { |
|
| 42 | 42 | throw new ErrorException($message, 0, $level, $file, $line); |
| 43 | 43 | } |
| 44 | 44 | }); |
@@ -50,11 +50,11 @@ discard block |
||
| 50 | 50 | */ |
| 51 | 51 | public static function registerAssertionHandler(LoggerInterface $logger, $logLevel) { |
| 52 | 52 | static $errorLogger = null; |
| 53 | - if($errorLogger === null) { |
|
| 53 | + if ($errorLogger === null) { |
|
| 54 | 54 | $errorLogger = new LoggerCollection(); |
| 55 | 55 | assert_options(ASSERT_ACTIVE, true); |
| 56 | 56 | assert_options(ASSERT_WARNING, false); |
| 57 | - assert_options(ASSERT_CALLBACK, function ($file, $line, $message) use ($errorLogger, $logLevel) { |
|
| 57 | + assert_options(ASSERT_CALLBACK, function($file, $line, $message) use ($errorLogger, $logLevel) { |
|
| 58 | 58 | $errorLogger->log($logLevel, $message, [ |
| 59 | 59 | 'file' => $file, |
| 60 | 60 | 'line' => $line |
@@ -69,12 +69,12 @@ discard block |
||
| 69 | 69 | */ |
| 70 | 70 | public static function registerFatalErrorHandler(LoggerInterface $logger) { |
| 71 | 71 | static $errorLogger = null; |
| 72 | - if($errorLogger === null) { |
|
| 72 | + if ($errorLogger === null) { |
|
| 73 | 73 | $errorLogger = new LoggerCollection(); |
| 74 | 74 | $errorLevels = self::$phpErrorLevels; |
| 75 | - register_shutdown_function(function () use ($errorLogger, $errorLevels) { |
|
| 75 | + register_shutdown_function(function() use ($errorLogger, $errorLevels) { |
|
| 76 | 76 | $error = error_get_last(); |
| 77 | - if($error !== null && $error['type'] === E_ERROR) { |
|
| 77 | + if ($error !== null && $error['type'] === E_ERROR) { |
|
| 78 | 78 | $errorLogger = new LogLevelRangeFilter($errorLogger, LogLevel::ERROR); |
| 79 | 79 | $errorLogger->log(LogLevel::ALERT, $error['message'], $error); |
| 80 | 80 | } |
@@ -85,9 +85,9 @@ discard block |
||
| 85 | 85 | |
| 86 | 86 | public static function registerExceptionHandler(LoggerInterface $logger) { |
| 87 | 87 | static $errorLogger = null; |
| 88 | - if($errorLogger === null) { |
|
| 88 | + if ($errorLogger === null) { |
|
| 89 | 89 | $errorLogger = new LoggerCollection(); |
| 90 | - set_exception_handler(static function ($exception) use ($errorLogger) { |
|
| 90 | + set_exception_handler(static function($exception) use ($errorLogger) { |
|
| 91 | 91 | /** @var Exception|Throwable $exception */ |
| 92 | 92 | $errorLogger = new LogLevelRangeFilter($errorLogger, LogLevel::ERROR); |
| 93 | 93 | try { |
@@ -95,7 +95,7 @@ discard block |
||
| 95 | 95 | } catch (Throwable $e) { |
| 96 | 96 | $errorLogger->log(LogLevel::CRITICAL, $exception->getMessage(), ['exception' => self::getExceptionAsArray($exception, false, false)]); |
| 97 | 97 | } |
| 98 | - if($exception instanceof Throwable && !($exception instanceof Error)) { |
|
| 98 | + if ($exception instanceof Throwable && !($exception instanceof Error)) { |
|
| 99 | 99 | StackTracePrinter::printException($exception, "PHP Fatal Error: Uncaught exception: "); |
| 100 | 100 | die(1); |
| 101 | 101 | } |
@@ -111,7 +111,7 @@ discard block |
||
| 111 | 111 | * @return array|null |
| 112 | 112 | */ |
| 113 | 113 | private static function getExceptionAsArray($exception, bool $previous, bool $withTrace) { |
| 114 | - if($exception === null) { |
|
| 114 | + if ($exception === null) { |
|
| 115 | 115 | return null; |
| 116 | 116 | } |
| 117 | 117 | return [ |