lithium\analysis\Debugger::_closureDef PHP Method

_closureDef() protected static method

Helper method for caching closure function references to help the process of building the stack trace.
protected static _closureDef ( array $frame, callable | string $function ) : string
$frame array Backtrace information.
$function callable | string The method related to $frame information.
return string Returns either the cached or the fetched closure function reference while writing its reference to the cache array `$_closureCache`.
    protected static function _closureDef($frame, $function)
    {
        $reference = '::';
        $frame += array('file' => '??', 'line' => '??');
        $cacheKey = "{$frame['file']}@{$frame['line']}";
        if (isset(static::$_closureCache[$cacheKey])) {
            return static::$_closureCache[$cacheKey];
        }
        if ($class = Inspector::classes(array('file' => $frame['file']))) {
            foreach (Inspector::methods(key($class), 'extents') as $method => $extents) {
                $line = $frame['line'];
                if (!($extents[0] <= $line && $line <= $extents[1])) {
                    continue;
                }
                $class = key($class);
                $reference = "{$class}::{$method}";
                $function = "{$reference}()::{closure}";
                break;
            }
        } else {
            $reference = $frame['file'];
            $function = "{$reference}::{closure}";
        }
        $line = static::_definition($reference, $frame['line']) ?: '?';
        $function .= " @ {$line}";
        return static::$_closureCache[$cacheKey] = $function;
    }