1 | <?php |
||
27 | abstract class ErrorHandler extends Component |
||
28 | { |
||
29 | /** |
||
30 | * @var bool whether to discard any existing page output before error display. Defaults to true. |
||
31 | */ |
||
32 | public $discardExistingOutput = true; |
||
33 | /** |
||
34 | * @var int the size of the reserved memory. A portion of memory is pre-allocated so that |
||
35 | * when an out-of-memory issue occurs, the error handler is able to handle the error with |
||
36 | * the help of this reserved memory. If you set this value to be 0, no memory will be reserved. |
||
37 | * Defaults to 256KB. |
||
38 | */ |
||
39 | public $memoryReserveSize = 262144; |
||
40 | /** |
||
41 | * @var \Exception|null the exception that is being handled currently. |
||
42 | */ |
||
43 | public $exception; |
||
44 | |||
45 | /** |
||
46 | * @var string Used to reserve memory for fatal error handler. |
||
47 | */ |
||
48 | private $_memoryReserve; |
||
49 | |||
50 | |||
51 | /** |
||
52 | * Register this error handler. |
||
53 | */ |
||
54 | public function register() |
||
65 | |||
66 | /** |
||
67 | * Unregisters this error handler by restoring the PHP error and exception handlers. |
||
68 | */ |
||
69 | public function unregister() |
||
74 | |||
75 | /** |
||
76 | * Handles uncaught PHP exceptions. |
||
77 | * |
||
78 | * This method is implemented as a PHP exception handler. |
||
79 | * |
||
80 | * @param \Exception $exception the exception that is not caught |
||
81 | */ |
||
82 | public function handleException($exception) |
||
117 | |||
118 | /** |
||
119 | * Handles exception thrown during exception processing in [[handleException()]]. |
||
120 | * @param \Throwable $exception Exception that was thrown during main exception processing. |
||
121 | * @param \Exception $previousException Main exception processed in [[handleException()]]. |
||
122 | * @since 2.0.11 |
||
123 | */ |
||
124 | protected function handleFallbackExceptionMessage($exception, $previousException) |
||
143 | |||
144 | /** |
||
145 | * Handles PHP execution errors such as warnings and notices. |
||
146 | * |
||
147 | * This method is used as a PHP error handler. It will simply raise an [[ErrorException]]. |
||
148 | * |
||
149 | * @param int $code the level of the error raised. |
||
150 | * @param string $message the error message. |
||
151 | * @param string $file the filename that the error was raised in. |
||
152 | * @param int $line the line number the error was raised at. |
||
153 | * @return bool whether the normal error handler continues. |
||
154 | * |
||
155 | * @throws ErrorException |
||
156 | */ |
||
157 | public function handleError($code, $message, $file, $line) |
||
182 | |||
183 | /** |
||
184 | * Handles fatal PHP errors. |
||
185 | */ |
||
186 | public function handleFatalError() |
||
215 | |||
216 | /** |
||
217 | * Renders the exception. |
||
218 | * @param \Exception $exception the exception to be rendered. |
||
219 | */ |
||
220 | abstract protected function renderException($exception); |
||
221 | |||
222 | /** |
||
223 | * Logs the given exception. |
||
224 | * @param \Exception $exception the exception to be logged |
||
225 | * @since 2.0.3 this method is now public. |
||
226 | */ |
||
227 | public function logException($exception) |
||
237 | |||
238 | /** |
||
239 | * Removes all output echoed before calling this method. |
||
240 | */ |
||
241 | public function clearOutput() |
||
250 | |||
251 | /** |
||
252 | * Converts an exception into a PHP error. |
||
253 | * |
||
254 | * This method can be used to convert exceptions inside of methods like `__toString()` |
||
255 | * to PHP errors because exceptions cannot be thrown inside of them. |
||
256 | * @param \Exception $exception the exception to convert to a PHP error. |
||
257 | */ |
||
258 | public static function convertExceptionToError($exception) |
||
262 | |||
263 | /** |
||
264 | * Converts an exception into a simple string. |
||
265 | * @param \Exception|\Error $exception the exception being converted |
||
266 | * @return string the string representation of the exception. |
||
267 | */ |
||
268 | 5 | public static function convertExceptionToString($exception) |
|
289 | |||
290 | /** |
||
291 | * Attempts to flush logger messages. |
||
292 | * @since 2.1 |
||
293 | */ |
||
294 | protected function flushLogger() |
||
304 | } |
||
305 |
This error could be the result of:
1. Missing dependencies
PHP Analyzer uses your
composer.json
file (if available) to determine the dependencies of your project and to determine all the available classes and functions. It expects thecomposer.json
to be in the root folder of your repository.Are you sure this class is defined by one of your dependencies, or did you maybe not list a dependency in either the
require
orrequire-dev
section?2. Missing use statement
PHP does not complain about undefined classes in
ìnstanceof
checks. For example, the following PHP code will work perfectly fine:If you have not tested against this specific condition, such errors might go unnoticed.