public static function registerErrorHandler() { static::$previousHandlers['error'] = set_error_handler(function ($errno, $errstr, $errfile = null, $errline = 0, array $errcontext = array()) { Debugger::handleError($errno, $errstr, $errfile, $errline, $errcontext); if (Debugger::$previousHandlers['error']) { call_user_func(Debugger::$previousHandlers['error'], $errno, $errstr, $errfile, $errline, $errcontext); } }); }