Completed
Push — master ( 0ce447...2561e7 )
by Ron
49s
created
src/CoreErrorHandlers.php 1 patch
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -30,15 +30,15 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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 [
Please login to merge, or discard this patch.