Skip to content

Commit dbfd0ec

Browse files
committed
[Debug] Add link to the output of debug function
1 parent 07f61f1 commit dbfd0ec

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

DataCollector/DumpDataCollector.php

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,15 +26,17 @@
2626
class DumpDataCollector extends DataCollector implements DataDumperInterface
2727
{
2828
private $stopwatch;
29+
private $fileLinkFormat;
2930
private $dataCount = 0;
3031
private $isCollected = true;
3132
private $clonesCount = 0;
3233
private $clonesIndex = 0;
3334
private $rootRefs;
3435

35-
public function __construct(Stopwatch $stopwatch = null)
36+
public function __construct(Stopwatch $stopwatch = null, $fileLinkFormat = null)
3637
{
3738
$this->stopwatch = $stopwatch;
39+
$this->fileLinkFormat = $fileLinkFormat ?: ini_get('xdebug.file_link_format') ?: get_cfg_var('xdebug.file_link_format');
3840

3941
// All clones share these properties by reference:
4042
$this->rootRefs = array(
@@ -213,7 +215,12 @@ public function __destruct()
213215
$dump['name'] = htmlspecialchars($dump['name'], ENT_QUOTES, 'UTF-8');
214216
$dump['file'] = htmlspecialchars($dump['file'], ENT_QUOTES, 'UTF-8');
215217
if ('' !== $dump['file']) {
216-
$dump['name'] = "<abbr title=\"{$dump['file']}\">{$dump['name']}</abbr>";
218+
if ($this->fileLinkFormat) {
219+
$link = strtr($this->fileLinkFormat, array('%f' => $dump['file'], '%l' => $dump['line']));
220+
$dump['name'] = sprintf('<a href="%s" title="%s">%s</a>', $link, $dump['file'], $dump['name']);
221+
} else {
222+
$dump['name'] = sprintf('<abbr title="%s">%s</abbr>', $dump['file'], $dump['name']);
223+
}
217224
}
218225
echo "\n<span class=\"sf-dump-meta\">{$dump['name']} on line {$dump['line']}:</span>";
219226
} else {

0 commit comments

Comments
 (0)