Habari\Error::error_handler PHP Method

error_handler() public static method

Used to handle all PHP errors after Error::handle_errors() is called.
public static error_handler ( $errno, $errstr, $errfile, $errline, $errcontext )
    public static function error_handler($errno, $errstr, $errfile, $errline, $errcontext)
    {
        if (($errno & error_reporting()) === 0) {
            return;
        }
        if (!function_exists('\\Habari\\_t') && !function_exists('_t')) {
            function _t($v)
            {
                return $v;
            }
            function _n($singular, $plural, $count)
            {
                return $count == 1 ? $singular : $plural;
            }
        }
        if (!defined('DEBUG')) {
            define('DEBUG', false);
        }
        // Don't be fooled, we can't actually handle most of these.
        $error_names = array(E_ERROR => _t('Error'), E_WARNING => _t('Warning'), E_PARSE => _t('Parse Error'), E_NOTICE => _t('Notice'), E_CORE_ERROR => _t('Core Error'), E_CORE_WARNING => _t('Core Warning'), E_COMPILE_ERROR => _t('Compile Error'), E_COMPILE_WARNING => _t('Compile Warning'), E_USER_ERROR => _t('User Error'), E_USER_WARNING => _t('User Warning'), E_USER_NOTICE => _t('User Notice'), E_STRICT => _t('Strict Notice'), E_RECOVERABLE_ERROR => _t('Recoverable Error'), E_DEPRECATED => _t('Deprecated violation'), E_USER_DEPRECATED => _t('User deprecated violation'));
        if (strpos($errfile, HABARI_PATH) === 0) {
            $errfile = substr($errfile, strlen(HABARI_PATH) + 1);
        }
        if (ini_get('display_errors') || DEBUG) {
            printf("<pre class=\"error\">\n<b>%s:</b> %s in %s line %s\n</pre>", $error_names[$errno], $errstr, $errfile, $errline);
            if (DEBUG) {
                Error::print_backtrace();
            }
            if (Options::get('log_backtraces', false) || DEBUG) {
                $backtrace = print_r(debug_backtrace(), true);
            } else {
                $backtrace = null;
            }
        }
        if (!isset($backtrace)) {
            $backtrace = null;
        }
        if (DB::is_connected()) {
            EventLog::log($errstr . ' in ' . $errfile . ':' . $errline, 'err', 'default', null, $backtrace);
        }
        // throwing an Error make every error fatal!
        //throw new Error($errstr, 0, true);
    }