Skip to content

Commit 7878b0f

Browse files
committed
Added option to set a callback to get file/line
1 parent 968ee9c commit 7878b0f

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

examples/array.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,6 @@
1919
)
2020
)
2121
);
22-
ldd(new \Exception('mierda'));
22+
2323
$ladybug = new \Ladybug\Dumper();
2424
echo $ladybug->dump($var);

src/Ladybug/Dumper.php

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,8 @@ class Dumper
4343
/** @var int $callLine */
4444
protected $callLine = null;
4545

46+
protected $callLineFileCallback = null;
47+
4648
protected $xdebugLink = null;
4749

4850
/** @var array $options */
@@ -167,6 +169,13 @@ public function loadCallLocationInfo()
167169
$this->callFile = isset($backtrace[$idx]['file']) ? $backtrace[$idx]['file'] : null;
168170
$this->callLine = isset($backtrace[$idx]['line']) ? $backtrace[$idx]['line'] : null;
169171

172+
if (!is_null($this->callLineFileCallback)) {
173+
list($this->callFile, $this->callLine) = call_user_func_array($this->callLineFileCallback, array(
174+
$this->callFile,
175+
$this->callLine
176+
));
177+
}
178+
170179
$xdebugLink = ini_get('xdebug.file_link_format');
171180
if (!empty($xdebugLink)) {
172181
$this->xdebugLink = str_replace(array('%f', '%l'), array($this->callFile, $this->callLine), $xdebugLink);
@@ -307,4 +316,10 @@ public function getOptions()
307316
return $this->options;
308317
}
309318

319+
public function setCallLineFileCallback($callLineFileCallback)
320+
{
321+
$this->callLineFileCallback = $callLineFileCallback;
322+
}
323+
324+
310325
}

0 commit comments

Comments
 (0)