Skip to content

Instantly share code, notes, and snippets.

@JanTvrdik
Forked from fprochazka/whereCalled.php
Created April 12, 2011 18:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save JanTvrdik/916144 to your computer and use it in GitHub Desktop.
Save JanTvrdik/916144 to your computer and use it in GitHub Desktop.
<?php
function wc($level = 1) {
if (\Nette\Debug::$productionMode) { return; }
$o = function ($t) { return (isset($t->class) ? htmlspecialchars($t->class) . "->" : NULL) . htmlspecialchars($t->function) . '()'; };
$f = function ($t) {
$file = defined('APP_DIR') ? 'app' . str_replace(realpath(APP_DIR), '', realpath($t->file)) : $t->file;
return '<a href="' . \Nette\DebugHelpers::editorLink($t->file, $t->line) . '">' . htmlspecialchars($file) . ':' . (int)$t->line . '</a>';
};
$trace = debug_backtrace();
$target = (object)$trace[$level];
$caller = (object)$trace[$level+1];
echo "<pre class='nette-dump'>" . $o($target) . " called from " . $o($caller) . " (" . $f($caller) . ")</pre>";
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment