Get a description of the (caller's) caller from debug_backtrace()
Returns an associative array with zero or more of the following values.
Separators are added as needed to allow concatenation to a caller string.
-
namespace
-
class
-
file
-
function
-
line
The return values below, for example, would implode to:
-
Salient\Tests\Utility\Debug\GetCallerClass->getCallerViaMethod:23
-
/path/to/tests/fixtures/Toolkit/Utility/Debug/GetCallerFile1.php::{closure}:29
<?php
[
'namespace' => 'Salient\\Tests\\Utility\\Debug\\',
'class' => 'GetCallerClass',
'->',
'function' => 'getCallerViaMethod',
':',
'line' => 23,
];
[
'file' => '/path/to/tests/fixtures/Toolkit/Utility/Debug/GetCallerFile1.php',
'::',
'function' => '{closure}',
':',
'line' => 29,
];
For an earlier frame in the call stack, set $depth
to 1
or higher.