1 | <?php |
||
5 | class ErrorHandler |
||
6 | { |
||
7 | |||
8 | /** |
||
9 | * Register the default error handling |
||
10 | */ |
||
11 | public static function register() |
||
19 | |||
20 | /** |
||
21 | * Default Exception handler to show a nice user message before dieing |
||
22 | * |
||
23 | * The exception is logged to the error log |
||
24 | * |
||
25 | * @param \Throwable $e |
||
26 | */ |
||
27 | public static function fatalException($e) |
||
52 | |||
53 | /** |
||
54 | * Convenience method to display an error message for the given Exception |
||
55 | * |
||
56 | * @param \Throwable $e |
||
57 | * @param string $intro |
||
58 | */ |
||
59 | public static function showExceptionMsg($e, $intro = 'Error!') |
||
65 | |||
66 | /** |
||
67 | * Default error handler to convert old school warnings, notices, etc to exceptions |
||
68 | * |
||
69 | * You should not need to call this directly! |
||
70 | * |
||
71 | * @param int $errno |
||
72 | * @param string $errstr |
||
73 | * @param string $errfile |
||
74 | * @param int $errline |
||
75 | * @return bool |
||
76 | * @throws \ErrorException |
||
77 | */ |
||
78 | public static function errorConverter($errno, $errstr, $errfile, $errline) |
||
89 | |||
90 | /** |
||
91 | * Last resort to handle fatal errors that still can't be cought |
||
92 | */ |
||
93 | public static function fatalShutdown() |
||
113 | |||
114 | /** |
||
115 | * Log the given exception to the error log |
||
116 | * |
||
117 | * @param \Throwable $e |
||
118 | * @return bool false if the logging failed |
||
119 | */ |
||
120 | public static function logException($e) |
||
133 | |||
134 | /** |
||
135 | * Checks the the stacktrace for plugin files |
||
136 | * |
||
137 | * @param \Throwable $e |
||
138 | * @return false|string |
||
139 | */ |
||
140 | protected static function guessPlugin($e) |
||
160 | } |
||
161 |
In PHP, under loose comparison (like
==
, or!=
, orswitch
conditions), values of different types might be equal.For
string
values, the empty string''
is a special case, in particular the following results might be unexpected: