File tree Expand file tree Collapse file tree 2 files changed +22
-1
lines changed Expand file tree Collapse file tree 2 files changed +22
-1
lines changed Original file line number Diff line number Diff line change @@ -224,7 +224,7 @@ public static function printVars(...$args): string
224224 $ string = '' ;
225225
226226 foreach ($ args as $ arg ) {
227- $ string .= print_r ($ arg , 1 ) . PHP_EOL ;
227+ $ string .= print_r ($ arg , true ) . PHP_EOL ;
228228 }
229229
230230 return preg_replace ("/Array \n\s+\(/ " , 'Array ( ' , $ string );
Original file line number Diff line number Diff line change @@ -21,6 +21,27 @@ function vdump(...$vars)
2121 }
2222}
2323
24+ if (!function_exists ('pdump ' )) {
25+ /**
26+ * Dump data like var_dump
27+ *
28+ * @param mixed ...$vars
29+ */
30+ function pdump (...$ vars )
31+ {
32+ $ trace = debug_backtrace (DEBUG_BACKTRACE_IGNORE_ARGS , 2 );
33+
34+ $ line = $ trace [0 ]['line ' ];
35+ $ pos = $ trace [1 ]['class ' ] ?? $ trace [0 ]['file ' ];
36+
37+ if ($ pos ) {
38+ echo "CALL ON $ pos( $ line): \n" ;
39+ }
40+
41+ echo Toolkit \Stdlib \Php::printVars (...$ vars ), PHP_EOL ;
42+ }
43+ }
44+
2445if (!function_exists ('edump ' )) {
2546 /**
2647 * Dump data like var_dump, will call exit() on print after.
You can’t perform that action at this time.
0 commit comments