@@ -14,11 +14,11 @@ discard block |
||
| 14 | 14 | // just to load the class, required to get the shortcuts defined in namespace \ |
| 15 | 15 | } |
| 16 | 16 | |
| 17 | - public static function display_errors($error_message=null) |
|
| 17 | + public static function display_errors($error_message = null) |
|
| 18 | 18 | { |
| 19 | 19 | $should_display = ini_get('display_errors') == '1'; |
| 20 | 20 | |
| 21 | - if($should_display && !empty($error_message)) |
|
| 21 | + if ($should_display && !empty($error_message)) |
|
| 22 | 22 | echo('<pre style="z-index:9999; background-color:#FFF; color:#000; padding:0.5em; font-size:0.7em; margin:0 0 1em 0; font-family:courier;">'.$error_message.'</pre>'); |
| 23 | 23 | } |
| 24 | 24 | |
@@ -41,7 +41,7 @@ discard block |
||
| 41 | 41 | { |
| 42 | 42 | $short_file_path_length = 5; |
| 43 | 43 | |
| 44 | - if(is_object($var) && (is_subclass_of($var, 'Error') || is_subclass_of($var, 'Exception'))) |
|
| 44 | + if (is_object($var) && (is_subclass_of($var, 'Error') || is_subclass_of($var, 'Exception'))) |
|
| 45 | 45 | { |
| 46 | 46 | $backtrace = $var->getTrace(); |
| 47 | 47 | $full_backtrace = true; |
@@ -68,7 +68,7 @@ discard block |
||
| 68 | 68 | } |
| 69 | 69 | |
| 70 | 70 | // ----------------------------------------------------------- formatting : shorten file path to [self::REDUCE_FILE_PATH_DEPTH_TO] elements |
| 71 | - public static function format_file($file,$reduce_file_depth_to = 5) |
|
| 71 | + public static function format_file($file, $reduce_file_depth_to = 5) |
|
| 72 | 72 | { |
| 73 | 73 | return implode('/', array_slice(explode('/', $file), -$reduce_file_depth_to, $reduce_file_depth_to)); |
| 74 | 74 | } |
@@ -78,30 +78,30 @@ discard block |
||
| 78 | 78 | { |
| 79 | 79 | $formated_traces = []; |
| 80 | 80 | |
| 81 | - foreach($traces as $depth => $trace) |
|
| 81 | + foreach ($traces as $depth => $trace) |
|
| 82 | 82 | { |
| 83 | 83 | $function_name = $trace['function'] ?? '?'; |
| 84 | 84 | |
| 85 | 85 | $class_name = $trace['class'] ?? '?'; |
| 86 | 86 | |
| 87 | - if(($function_name === 'dump' || $function_name === 'vd' || $function_name === 'dd') && $class_name === __CLASS__) |
|
| 87 | + if (($function_name === 'dump' || $function_name === 'vd' || $function_name === 'dd') && $class_name === __CLASS__) |
|
| 88 | 88 | continue; |
| 89 | 89 | |
| 90 | - if($function_name !== 'vd' && $function_name !== 'dd' && $function_name !== 'vdt' && $function_name !== 'ddt' && isset($trace['args'])) |
|
| 90 | + if ($function_name !== 'vd' && $function_name !== 'dd' && $function_name !== 'vdt' && $function_name !== 'ddt' && isset($trace['args'])) |
|
| 91 | 91 | { |
| 92 | 92 | $args = []; |
| 93 | - foreach($trace['args'] as $arg) |
|
| 93 | + foreach ($trace['args'] as $arg) |
|
| 94 | 94 | { |
| 95 | - if(is_null($arg)) |
|
| 96 | - $args[]= 'null'; |
|
| 97 | - elseif(is_bool($arg)) |
|
| 98 | - $args[]= $arg === true ? 'bool:true' : 'bool:false'; |
|
| 99 | - elseif(is_string($arg) || is_numeric($arg)) |
|
| 100 | - $args[]= $arg; |
|
| 101 | - elseif(is_object($arg)) |
|
| 102 | - $args[]= get_class($arg); |
|
| 103 | - elseif(is_array($arg)) |
|
| 104 | - $args[]= 'Array #'.count($arg); |
|
| 95 | + if (is_null($arg)) |
|
| 96 | + $args[] = 'null'; |
|
| 97 | + elseif (is_bool($arg)) |
|
| 98 | + $args[] = $arg === true ? 'bool:true' : 'bool:false'; |
|
| 99 | + elseif (is_string($arg) || is_numeric($arg)) |
|
| 100 | + $args[] = $arg; |
|
| 101 | + elseif (is_object($arg)) |
|
| 102 | + $args[] = get_class($arg); |
|
| 103 | + elseif (is_array($arg)) |
|
| 104 | + $args[] = 'Array #'.count($arg); |
|
| 105 | 105 | else |
| 106 | 106 | { |
| 107 | 107 | var_dump($arg); |
@@ -116,9 +116,9 @@ discard block |
||
| 116 | 116 | $call_file = isset($trace['file']) ? pathinfo($trace['file'], PATHINFO_BASENAME) : '?'; |
| 117 | 117 | $call_line = $trace['line'] ?? '?'; |
| 118 | 118 | |
| 119 | - $formated_traces []= sprintf('[%-23.23s %3s] %'.($depth*3).'s%s%s(%s)', $call_file, $call_line,' ', "$class_name::", $function_name, $args); |
|
| 119 | + $formated_traces [] = sprintf('[%-23.23s %3s] %'.($depth*3).'s%s%s(%s)', $call_file, $call_line, ' ', "$class_name::", $function_name, $args); |
|
| 120 | 120 | |
| 121 | - if($full_backtrace === false) |
|
| 121 | + if ($full_backtrace === false) |
|
| 122 | 122 | break; |
| 123 | 123 | } |
| 124 | 124 | |
@@ -129,17 +129,17 @@ discard block |
||
| 129 | 129 | |
| 130 | 130 | namespace |
| 131 | 131 | { |
| 132 | - if(!function_exists('vd')) { |
|
| 133 | - function vd($var, $var_name=null){ return \HexMakina\Debugger\Debugger::vd($var, $var_name, false);} |
|
| 132 | + if (!function_exists('vd')) { |
|
| 133 | + function vd($var, $var_name = null) { return \HexMakina\Debugger\Debugger::vd($var, $var_name, false); } |
|
| 134 | 134 | } |
| 135 | - if(!function_exists('dd')) { |
|
| 136 | - function dd($var, $var_name=null){ return \HexMakina\Debugger\Debugger::dd($var, $var_name, false);} |
|
| 135 | + if (!function_exists('dd')) { |
|
| 136 | + function dd($var, $var_name = null) { return \HexMakina\Debugger\Debugger::dd($var, $var_name, false); } |
|
| 137 | 137 | } |
| 138 | - if(!function_exists('vdt')) { |
|
| 139 | - function vdt($var, $var_name=null){ return \HexMakina\Debugger\Debugger::vd($var, $var_name, true);} |
|
| 138 | + if (!function_exists('vdt')) { |
|
| 139 | + function vdt($var, $var_name = null) { return \HexMakina\Debugger\Debugger::vd($var, $var_name, true); } |
|
| 140 | 140 | } |
| 141 | - if(!function_exists('ddt')) { |
|
| 142 | - function ddt($var, $var_name=null){ return \HexMakina\Debugger\Debugger::dd($var, $var_name, true);} |
|
| 141 | + if (!function_exists('ddt')) { |
|
| 142 | + function ddt($var, $var_name = null) { return \HexMakina\Debugger\Debugger::dd($var, $var_name, true); } |
|
| 143 | 143 | } |
| 144 | 144 | } |
| 145 | 145 | ?> |