public static function emit_php_error($number, $error, $file, $line, $options = array('show-errors' => E_ALL))
{
if ($number != E_ERROR && !isset($options['show-wp-errors']) && Whippet::file_is_in_core($file, $options)) {
return;
}
$error_type = array(E_ERROR => 'Fatal error', E_WARNING => 'Warning', E_PARSE => 'Parsing error', E_NOTICE => 'Notice', E_CORE_ERROR => 'Core error', E_CORE_WARNING => 'Core warning', E_COMPILE_ERROR => 'Compile error', E_COMPILE_WARNING => 'Compile warning', E_USER_ERROR => 'User error', E_USER_WARNING => 'User warning', E_USER_NOTICE => 'User notice', E_STRICT => 'Strict notice', E_RECOVERABLE_ERROR => 'Recoverable error', E_DEPRECATED => 'Deprecated', E_USER_DEPRECATED => 'User Deprecated');
// If the error is unknown, pass it through directly
if (empty($error_type[$number])) {
$error_type[$number] = $number;
}
// Should we show this error?
if (($number & $options['show-errors']) != $number) {
return;
}
// Display the error
Whippet::message(Colours::fg('bold_red') . $error_type[$number] . Colours::fg('red') . ": " . $error . Colours::fg('brown') . " in " . $file . " at line {$line}" . Colours::off());
// Show a notification, if we've got libnotify
if (!empty($options['libnotify']) && $number === E_ERROR) {
$message = "{$error_type[$number]}: {$error} in {$file} at line {$line}";
$message = str_replace("'", "\\'", $message);
exec("{$options['libnotify']} -i error 'Whippet' '{$message}'");
}
}