@ 2018-03-31T17:28:27Z <?php
if(!defined('E_DEPRECATED')){
define('E_DEPRECATED', 0);
}
if(!defined('E_USER_DEPRECATED')){
define('E_USER_DEPRECATED', 0);
}
const EHS_ERRORS = array(
E_ERROR => array('ERROR', 'Error'),
E_WARNING => array('WARNING', 'Warning'),
E_PARSE => array('PARSE', 'Parsing Error'),
E_NOTICE => array('NOTICE', 'Notice'),
E_CORE_ERROR => array('CORE_ERROR', 'Core Error'),
E_CORE_WARNING => array('CORE_WARNING', 'Core Warning'),
E_COMPILE_ERROR => array('COMPILE_ERROR', 'Compile Error'),
E_COMPILE_WARNING => array('COMPILE_WARNING', 'Compile Warning'),
E_USER_ERROR => array('USER_ERROR', 'Triggered Error'),
E_USER_WARNING => array('USER_WARNING', 'Triggered Warning'),
E_USER_NOTICE => array('USER_NOTICE', 'Triggered Notice'),
E_STRICT => array('STRICT', 'Strict Standarts'),
E_RECOVERABLE_ERROR => array('RECOVERABLE_ERROR', 'Catchable Fatal Error'),
E_DEPRECATED => array('DEPRECATED', 'Deprecated'),
E_USER_DEPRECATED => array('USER_DEPRECATED', 'Triggered Deprecated')
);
define('EHS_CHECK_TOKENS_RGX', "/\(T_(".implode('|', array_keys(EHS_TOKENS)).")\)/");
define('EHS_NL', "<br>");
define('EHS_OPEN', "<div style='padding:1px;margin:1px 0;white-space:pre-wrap;border:1px solid black;word-wrap:break-word;'>");
define('EHS_SOURCE_OPEN', "<div style='padding:1px;margin:1px 0 0;white-space:pre-wrap;border:1px solid black;word-wrap:break-word;tab-size:2;font-family:monospace;'>");
define('EHS_CLOSE', "</div>");
define('EHS_OFF', 1);
define('EHS_GET_BACKTRACE', 2);
define('EHS_GET_SOURCE', 4);
define('EHS_GET_TOKEN_EXAMPLE',8);
define('EHS_GET_TOKEN_INFO', 16);
define('EHS_GET_MEMORY_USAGE', 32);
define('EHS_DEBUG', 64);
define('EHS_MUST_IGNORE_REPORTING', 128);
define('EHS_ALL', (4096 - 1) ^ EHS_OFF);
define('EHS_UTF', (extension_loaded('mbstring') ? (ini_get('mbstring.internal_encoding') == 'UTF-8') : false));
class EHS {
public static $previousAssertOptions = array();
public static $instance = null;
public $maxchars = 30;
public $linkFormat = '';
public $mask = 0;
public function __construct($mask = EHS_OFF){
if(self::$instance != null){
throw new Exception('EHS Object already exists, check EHS::$instance');
}
$this->mask = $mask;
self::$instance = &$this;
}
public function reporting($E = null){
if($E === null){
return error_reporting();
}else{
error_reporting($E);
}
return $this;
}
public function displayAllErrors(){
$this->reporting(E_ALL | E_STRICT);
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
return $this;
}
public function setup($error = false, $fatal = false, $exception = false, $assert = false){
if($error){
set_error_handler(array($this, 'ErrorHandler'));
}
if($fatal){
register_shutdown_function(array($this, 'FatalErrorHandler'));
ob_start();
}
if($exception){
set_exception_handler(array($this, 'ExceptionHandler'));
}
if($assert){
self::$previousAssertOptions[ASSERT_ACTIVE] = assert_options(ASSERT_ACTIVE);
self::$previousAssertOptions[ASSERT_WARNING] = assert_options(ASSERT_ACTIVE);
self::$previousAssertOptions[ASSERT_BAIL] = assert_options(ASSERT_BAIL);
self::$previousAssertOptions[ASSERT_QUIET_EVAL] = assert_options(ASSERT_QUIET_EVAL);
self::$previousAssertOptions[ASSERT_CALLBACK] = assert_options(ASSERT_CALLBACK);
assert_options(ASSERT_ACTIVE, 1);
assert_options(ASSERT_WARNING, 0);
assert_options(ASSERT_BAIL, 0);
assert_options(ASSERT_QUIET_EVAL, 0);
assert_options(ASSERT_CALLBACK, array($this, 'AssertionHandler'));
}
return $this;
}
public function setupEnvironment(){
ini_set('html_errors', 'On');
ini_set('docref_root', '');
ini_set('docref_ext', '');
ini_set('log_errors', 'On');
ini_set('log_errors_max_len', 0);
ini_set('ignore_repeated_errors', 'Off');
ini_set('ignore_repeated_source', 'Off');
ini_set('report_memleaks', 'Off');
ini_set('track_errors', 'On');
ini_set('xmlrpc_errors', 'Off');
ini_set('xmlrpc_error_number', 'Off');
ini_set('error_prepend_string', '');
ini_set('error_append_string', '');
return $this;
}
public function restore($error = false, $exception = false, $assert = false){
if($error){
restore_error_handler();
}
if($exception){
restore_exception_handler();
}
if($assert){
assert_options(ASSERT_ACTIVE, self::$previousAssertOptions[ASSERT_ACTIVE]);
assert_options(ASSERT_WARNING, self::$previousAssertOptions[ASSERT_WARNING]);
assert_options(ASSERT_BAIL, self::$previousAssertOptions[ASSERT_BAIL]);
assert_options(ASSERT_QUIET_EVAL, self::$previousAssertOptions[ASSERT_QUIET_EVAL]);
assert_options(ASSERT_CALLBACK, self::$previousAssertOptions[ASSERT_CALLBACK]);
}
return $this;
}
public function ErrorHandler($code, $message, $file, $line, $context = INF){
if(($this->mask & EHS_OFF) || ($ignored = $this->ignoreReporting($code)) == 'X'){
return false;
}else{
$debug = ($this->mask & EHS_DEBUG) || !($code & (E_NOTICE | E_USER_NOTICE | E_DEPRECATED | E_USER_DEPRECATED | E_STRICT));
$types = EHS_ERRORS[$code];
$text = EHS_OPEN;
$text .= "<b>[".date('d-M-Y H:i:s')."] $ignored [E_$types[0]]".(($this->mask & EHS_GET_MEMORY_USAGE) && $debug ? ' [Memory Usage: '.memory_get_usage().' Bytes]' : '')."</b>".EHS_NL;
$text .= "<b>$types[1]:</b> {$message}".EHS_NL;
$text .= " in <b>[{$this->formatLink($file, $line)}]</b>".EHS_NL;
if($debug){
$text .= $this->getErrorSourceCode($file, $line);
if($this->mask & EHS_GET_BACKTRACE){
$text .= $this->formatBacktrace($this->backtrace(), $context === INF ? 3 : 2);
}
}
echo $text.EHS_CLOSE;
return true;
}
}
public function FatalErrorHandler(){
$error = error_get_last();
if($error && $error['type'] & (E_ERROR | E_PARSE | E_COMPILE_ERROR | E_CORE_ERROR)){
while(ob_get_level()){
ob_end_clean();
}
$this->ErrorHandler($error['type'], $error['message'], $error['file'], $error['line']);
exit;
}else{
ob_end_flush();
}
}
public function ExceptionHandler($e){
$hasChain = !!$e->getPrevious();
$text = ($hasChain ? EHS_OPEN : '');
$date = date('d-M-Y H:i:s');
do{
if($e instanceof ErrorException){
$text .= $this->ErrorException($e, $date);
}else{
$text .= $this->Exception($e, $date);
}
}while($e = $e->getPrevious());
$text .= ($hasChain ? EHS_CLOSE : '');
echo $text;
}
protected function ErrorException($e, $date){
$code = $e->getCode();
$file = $e->getFile();
$line = $e->getLine();
$severity = $e->getSeverity();
$types = EHS_ERRORS[$severity] ?: array('UNKNOWN', 'Unknown');
$text = EHS_OPEN;
$text .= "<b>[$date] [E_$types[0]]".($code ? " [Code: $code]" : '')."</b>".EHS_NL;
$text .= "<b>$types[1] Exception:</b> {$e->getMessage()}".EHS_NL;
$text .= " thrown in <b>[{$this->formatLink($file, $line)}]</b>".EHS_NL;
$text .= $this->getErrorSourceCode($file, $line);
$text .= $this->formatBacktrace($e->getTrace());
$text .= EHS_CLOSE;
return $text;
}
protected function Exception($e, $date){
$code = $e->getCode();
$file = $e->getFile();
$line = $e->getLine();
$text = EHS_OPEN;
$text .= "<b>[$date]".($code ? " [Code: $code]" : '')."</b>".EHS_NL;
$text .= "<b>".get_class($e).":</b> {$e->getMessage()}".EHS_NL;
$text .= " thrown in <b>[{$this->formatLink($file, $line)}]</b>".EHS_NL;
$text .= $this->getErrorSourceCode($file, $line);
$text .= $this->formatBacktrace($e->getTrace());
$text .= EHS_CLOSE;
return $text;
}
public function AssertionHandler($file, $line, $code, $message = ''){
$text = EHS_OPEN;
$text .= "<b>[".date('d-M-Y H:i:s')."]</b>".EHS_NL;
$text .= "<b>Assertion Failed:</b> $message".($code ? " ($code)" : '').EHS_NL;
$text .= " in <b>[{$this->formatLink($file, $line)}]</b>".EHS_NL;
echo $text.EHS_CLOSE;
return true;
}
protected function formatBacktrace($trace, $init = 0){
$length = count($trace);
if($length > $init){
$text = EHS_SOURCE_OPEN.'Trace:';
for($i = $init; $i < $length; $i++){
$point = $trace[$i];
$text .= EHS_NL.' \–––> ';
$args = isset($point['args']) ? $this->formatArgs($point['args']) : '()';
$text .= isset($point['class']) ? $point['class'] : '';
$text .= isset($point['type']) ? $point['type'] : '';
$text .= isset($point['function']) ? $point['function'].$args : '???';
$text .= EHS_NL.' at ['.(isset($point['file']) ? $this->formatLink($point['file'], (isset($point['line']) ? $point['line'] : 0)) : 'unknown').']';
}
unset($trace);
return $text.EHS_CLOSE;
}else{
return '';
}
}
protected function getErrorSourceCode($file, $line){
if(($this->mask & EHS_GET_SOURCE) && $file && $line && ($lines = file($file)) !== false){
$max_length = $this->stringLength((string) ($line + 1));
$compile = function($num, $line) use ($max_length){
$out = $num.str_repeat(' ', $max_length - $this->stringLength((string) $num))." | ".htmlspecialchars($line);
return $out;
};
$text = EHS_SOURCE_OPEN;
$text .= ($lines[$line - 2] ? $compile($line - 1, $lines[$line - 2]) : '');
$text .= "<font style='display:block;background:rgba(255, 165, 165, 0.3);'>".$compile($line, $lines[$line - 1])."</font>";
$text .= ($lines[$line] ? $compile($line + 1, $lines[$line]) : '');
return $text.EHS_CLOSE;
}else{
return '';
}
}
protected function ignoreReporting($code){
if(!(error_reporting() & $code)){
if($this->mask & EHS_MUST_IGNORE_REPORTING){
return '@';
}else{
return 'X';
}
}
return '';
}
protected function formatLink($file, $line){
if(!$file || !$this->linkFormat){
return "{$this->shortFile($file)}:$line";
}
return "<a href='".str_replace(array('%f', '%l'), array(urlencode($file), $line), $this->linkFormat)."' style='color:black;'>{$this->shortFile($file)}:$line</a>";
}
protected function shortFile($file){
return str_replace($_SERVER['DOCUMENT_ROOT'], '', str_replace('\\', '/', $file));
}
protected function backtrace(){
if(defined('DEBUG_BACKTRACE_PROVIDE_OBJECT')){
return debug_backtrace(DEBUG_BACKTRACE_PROVIDE_OBJECT);
}else{
return debug_backtrace(true);
}
}
protected function formatString($str){
if($this->stringLength($str) > $this->maxchars){
if(EHS_UTF){
$str = trim(mb_substr($str, 0, $this->maxchars / 2)).'…'.trim(mb_substr($str, -$this->maxchars / 2));
}else{
$str = substr($str, 0, $this->maxchars / 2).'...'.substr($str, -$this->maxchars / 2);
}
}
return $str;
}
protected function stringLength($str){
if(EHS_UTF){
$strlen = mb_strlen($str);
}else{
$strlen = strlen($str);
}
return $strlen;
}
protected function formatArg($arg){
switch(gettype($arg)){
case 'boolean':
return $arg ? 'true' : 'false';
case 'NULL':
return 'null';
case 'integer':
case 'double':
case 'float':
$arg = (string) $arg;
if(EHS_UTF){
$arg = str_replace('INF', '∞', $arg);
}else{
$arg = str_replace('INF', 'Infinity', $arg);
}
$arg = str_replace('NAN', 'NaN', $arg);
return $arg;
case 'string':
if(is_callable($arg, false, $name)){
return "fs:$name";
}else if(class_exists($arg, false)){
return "c:$arg";
}else if(interface_exists($arg, false)){
return "i:$arg";
}else if(function_exists('trait_exists') && trait_exists($arg, false)){
return "t:$arg";
}else{
$strlen = $this->stringLength($arg);
$arg = $this->formatString($arg);
if($strlen <= $this->maxchars){
$arg = "\"$arg\"";
}else{
$arg = "\"$arg\"($strlen)";
}
return str_replace("\n", '\n', str_replace("\t", '\t', $arg));
}
case 'array':
if(is_callable($arg, false, $name)){
return "fa:$name";
}else{
return 'array('.count($arg).')';
}
case 'object':
$object = get_class($arg).'():'.spl_object_hash($arg);
if(is_callable($arg, false)){
$object = "fo:".$object;
}
return $object;
case 'resource':
return 'r:'.get_resource_type($arg);
default:
return 'unknown';
}
}
protected function formatArgs($args){
foreach($args as &$value){
$value = $this->formatArg($value);
}
return '('.implode(', ', $args).')';
}
}
?>
Enable javascript to submit You have javascript disabled. You will not be able to edit any code.
Here you find the average performance (time & memory) of each version. A grayed out version indicates it didn't complete successfully (based on exit-code).
Version System time (s) User time (s) Memory (MiB) 8.3.6 0.012 0.006 16.88 8.3.5 0.003 0.012 16.75 8.3.4 0.007 0.010 19.04 8.3.3 0.006 0.009 19.05 8.3.2 0.005 0.003 22.12 8.3.1 0.005 0.003 22.02 8.3.0 0.008 0.000 19.21 8.2.18 0.007 0.007 18.41 8.2.17 0.012 0.003 22.96 8.2.16 0.011 0.004 20.36 8.2.15 0.009 0.000 24.18 8.2.14 0.004 0.004 24.66 8.2.13 0.008 0.000 26.16 8.2.12 0.007 0.004 19.51 8.2.11 0.007 0.003 22.30 8.2.10 0.004 0.008 18.16 8.2.9 0.000 0.008 18.28 8.2.8 0.004 0.004 19.40 8.2.7 0.000 0.009 17.75 8.2.6 0.003 0.005 18.00 8.2.5 0.000 0.008 17.88 8.2.4 0.000 0.008 20.61 8.2.3 0.000 0.009 19.54 8.2.2 0.003 0.005 18.24 8.2.1 0.003 0.006 18.16 8.2.0 0.000 0.009 18.34 8.1.28 0.011 0.011 25.92 8.1.27 0.003 0.006 20.41 8.1.26 0.006 0.006 26.35 8.1.25 0.005 0.003 28.09 8.1.24 0.009 0.000 22.41 8.1.23 0.011 0.000 21.25 8.1.22 0.004 0.004 17.91 8.1.21 0.004 0.004 19.04 8.1.20 0.006 0.003 17.88 8.1.19 0.005 0.005 17.60 8.1.18 0.008 0.000 18.10 8.1.17 0.003 0.006 19.00 8.1.16 0.005 0.003 19.05 8.1.15 0.000 0.008 19.19 8.1.14 0.004 0.004 17.87 8.1.13 0.000 0.008 20.54 8.1.12 0.000 0.007 17.59 8.1.11 0.000 0.008 17.51 8.1.10 0.000 0.008 17.61 8.1.9 0.004 0.004 17.63 8.1.8 0.004 0.004 17.66 8.1.7 0.004 0.004 17.52 8.1.6 0.000 0.009 17.62 8.1.5 0.003 0.005 17.73 8.1.4 0.003 0.005 17.59 8.1.3 0.000 0.008 17.71 8.1.2 0.006 0.006 17.71 8.1.1 0.003 0.006 17.67 8.1.0 0.003 0.006 17.64 8.0.30 0.005 0.003 20.41 8.0.29 0.000 0.008 17.00 8.0.28 0.004 0.004 18.63 8.0.27 0.003 0.006 17.54 8.0.26 0.007 0.003 17.02 8.0.25 0.000 0.007 17.19 8.0.24 0.006 0.003 17.23 8.0.23 0.005 0.003 17.23 8.0.22 0.004 0.004 17.08 8.0.21 0.003 0.005 17.11 8.0.20 0.004 0.004 17.27 8.0.19 0.007 0.003 17.27 8.0.18 0.000 0.008 17.21 8.0.17 0.000 0.009 17.23 8.0.16 0.006 0.003 17.16 8.0.15 0.000 0.008 17.06 8.0.14 0.004 0.004 17.20 8.0.13 0.003 0.003 13.61 8.0.12 0.003 0.006 17.20 8.0.11 0.008 0.000 17.23 8.0.10 0.008 0.000 17.13 8.0.9 0.004 0.004 17.30 8.0.8 0.013 0.010 17.13 8.0.7 0.004 0.004 17.14 8.0.6 0.005 0.003 17.00 8.0.5 0.003 0.005 17.15 8.0.3 0.010 0.010 17.21 8.0.2 0.009 0.012 17.46 8.0.1 0.003 0.005 17.36 8.0.0 0.011 0.007 17.02 7.4.33 0.003 0.003 15.55 7.4.32 0.000 0.007 16.60 7.4.30 0.003 0.003 16.66 7.4.29 0.004 0.004 16.56 7.4.28 0.003 0.006 16.80 7.4.27 0.000 0.007 16.57 7.4.26 0.007 0.000 16.75 7.4.25 0.003 0.005 16.62 7.4.24 0.000 0.007 16.75 7.4.23 0.005 0.003 16.59 7.4.22 0.004 0.004 16.83 7.4.21 0.014 0.005 16.67 7.4.20 0.004 0.004 16.57 7.4.16 0.005 0.014 16.73 7.4.14 0.009 0.012 17.86 7.4.13 0.007 0.011 16.56 7.4.12 0.013 0.008 16.75 7.4.11 0.013 0.013 16.59 7.4.10 0.004 0.013 16.67 7.4.9 0.009 0.009 16.68 7.4.8 0.003 0.016 19.39 7.4.7 0.016 0.010 16.82 7.4.6 0.013 0.004 16.76 7.4.5 0.008 0.012 16.80 7.4.4 0.007 0.011 16.76 7.4.0 0.005 0.013 15.11 7.3.33 0.003 0.003 13.47 7.3.32 0.000 0.006 13.36 7.3.31 0.004 0.004 16.41 7.3.30 0.004 0.004 16.52 7.3.29 0.000 0.007 16.33 7.3.28 0.010 0.008 16.54 7.3.26 0.010 0.008 16.69 7.3.24 0.011 0.008 16.56 7.3.23 0.004 0.014 16.56 7.3.21 0.011 0.007 16.68 7.3.20 0.015 0.003 16.77 7.3.19 0.013 0.010 16.64 7.3.18 0.007 0.011 16.43 7.3.17 0.013 0.009 16.82 7.3.16 0.005 0.012 16.68 7.3.12 0.000 0.017 15.06 7.3.11 0.010 0.010 15.22 7.3.10 0.003 0.016 14.88 7.3.9 0.007 0.007 15.20 7.3.8 0.006 0.006 14.83 7.3.7 0.003 0.010 15.07 7.3.6 0.004 0.012 15.05 7.3.5 0.013 0.006 15.10 7.3.4 0.009 0.006 15.05 7.3.3 0.012 0.006 14.91 7.3.2 0.007 0.007 16.70 7.3.1 0.008 0.005 16.52 7.3.0 0.006 0.006 16.60 7.2.33 0.006 0.013 16.89 7.2.32 0.009 0.009 16.66 7.2.31 0.007 0.011 16.54 7.2.30 0.006 0.012 16.57 7.2.29 0.011 0.016 16.73 7.2.25 0.014 0.007 14.88 7.2.24 0.007 0.011 15.22 7.2.23 0.009 0.003 15.37 7.2.22 0.003 0.010 15.19 7.2.21 0.005 0.005 15.16 7.2.20 0.009 0.006 15.34 7.2.19 0.008 0.008 14.93 7.2.18 0.004 0.012 15.23 7.2.17 0.003 0.013 15.43 7.2.13 0.000 0.015 16.89 7.2.12 0.004 0.011 16.93 7.2.11 0.003 0.007 16.92 7.2.10 0.006 0.005 16.85 7.2.9 0.009 0.003 16.87 7.2.8 0.007 0.008 16.82 7.2.7 0.002 0.011 17.01 7.2.6 0.006 0.008 16.95 7.2.5 0.005 0.009 17.02 7.2.4 0.009 0.009 17.24 7.2.3 0.014 0.007 17.45 7.2.2 0.009 0.009 17.26 7.2.1 0.011 0.010 17.35 7.2.0 0.009 0.011 17.22 7.1.33 0.007 0.007 15.75 7.1.32 0.004 0.007 15.72 7.1.31 0.008 0.006 15.80 7.1.30 0.009 0.009 15.91 7.1.29 0.003 0.013 15.68 7.1.28 0.011 0.007 15.43 7.1.27 0.003 0.006 15.61 7.1.26 0.000 0.012 15.67 7.1.25 0.006 0.006 15.78 7.1.24 0.004 0.012 15.71 7.1.23 0.014 0.000 15.66 7.1.22 0.003 0.009 15.59 7.1.21 0.006 0.009 15.54 7.1.20 0.009 0.003 15.68 7.1.19 0.003 0.010 15.69 7.1.18 0.003 0.007 15.81 7.1.17 0.007 0.007 15.61 7.1.16 0.009 0.013 16.32 7.1.15 0.011 0.014 16.36 7.1.14 0.012 0.012 16.28 7.1.13 0.014 0.012 16.42 7.1.12 0.012 0.009 16.22 7.1.11 0.014 0.009 16.10 7.1.10 0.011 0.010 16.08 7.1.9 0.012 0.012 16.05 7.1.8 0.016 0.009 15.97 7.1.7 0.010 0.015 15.52 7.1.6 0.026 0.017 24.45 7.1.5 0.029 0.013 24.12 7.1.4 0.027 0.011 24.20 7.1.3 0.028 0.015 24.22 7.1.2 0.024 0.011 24.28 7.1.1 0.015 0.014 15.21 7.1.0 0.015 0.008 15.22 7.0.33 0.007 0.007 15.52 5.6.38 0.009 0.006 14.30
preferences:dark mode live preview
51.97 ms | 400 KiB | 5 Q