Created
November 20, 2020 15:05
-
-
Save kobus1998/3c41d82a42fc11c20d151df797379524 to your computer and use it in GitHub Desktop.
simple backtrace formatter
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* clear overview of backtrace | |
* | |
* @return string | |
*/ | |
function backTrace($traces = null) | |
{ | |
$traces = $traces ?? debug_backtrace(); | |
$result = ''; | |
foreach ($traces as $trace) | |
{ | |
$result .= sprintf("\n%s:%s %s()", $trace['file'], $trace['line'], "{$trace['class']}{$trace['type']}{$trace['function']}"); | |
} | |
return trim($result, "\n"); | |
} | |
/* result | |
path/to/file.php:69 foo::bar() | |
path/to/file.php:420 bar->foo() | |
path/to/file.php:1337 fooBar() | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment