trace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS, 3)[2] ?? [ "line" => -1, "file" => "unknown", ]; $this->content = $content; } public function renderArray() { return [ 'content' => $this->content, 'file' => $this->trace['file'] ?? '?', 'line' => $this->trace['line'] ?? '?', ]; } public function renderHtml() { $data = $this->getDumpContent(); $this->trace['file'] ??= "?"; $this->trace['line'] ??= "?"; return <<
[ file: {$this->trace['file']}:{$this->trace['line']} ]
$data HTML; } protected function getDumpContent() { ob_start(); var_dump(...($this->content !== [] ? $this->content : [null])); return ob_get_clean(); } }