Created
March 23, 2016 12:55
-
-
Save Thijzer/f1b7c312d34061d25f58 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
function generateCallTrace() | |
{ | |
$e = new \Exception(); | |
$trace = explode("\n", $e->getTraceAsString()); | |
// reverse array to make steps line up chronologically | |
$trace = array_reverse($trace); | |
array_shift($trace); // remove {main} | |
array_pop($trace); // remove call to this method | |
$length = count($trace); | |
$result = array(); | |
for ($i = 0; $i < $length; $i++) | |
{ | |
$result[] = ($i + 1) . ')' . substr($trace[$i], strpos($trace[$i], ' ')); // replace '#someNum' with '$i)', set the right ordering | |
} | |
return "\t" . implode("\n\t", $result); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
https://gist.github.com/dhaupin/d9d48328dbe312f6c0de