Skip to content

Commit 6e8a091

Browse files
Simplified link-to-source mapping definitions in debug.file_link_format
1 parent 32b80cd commit 6e8a091

File tree

1 file changed

+5
-7
lines changed

1 file changed

+5
-7
lines changed

DataCollector/DumpDataCollector.php

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,8 @@ public function __construct(Stopwatch $stopwatch = null, $fileLinkFormat = null,
4242
{
4343
$fileLinkFormat = $fileLinkFormat ?: ini_get('xdebug.file_link_format') ?: get_cfg_var('xdebug.file_link_format');
4444
if ($fileLinkFormat && !is_array($fileLinkFormat)) {
45-
$i = max(strpos($fileLinkFormat, '%f'), strpos($fileLinkFormat, '%l'));
46-
$i = strpos($fileLinkFormat, '#"', $i) ?: strlen($fileLinkFormat);
47-
$fileLinkFormat = array(substr($fileLinkFormat, 0, $i), substr($fileLinkFormat, $i + 1));
48-
$fileLinkFormat[1] = @json_decode('{'.$fileLinkFormat[1].'}', true) ?: array();
45+
$i = strpos($f = $fileLinkFormat, '&', max(strrpos($f, '%f'), strrpos($f, '%l'))) ?: strlen($f);
46+
$fileLinkFormat = array(substr($f, 0, $i)) + preg_split('/&([^>]++)>/', substr($f, $i), -1, PREG_SPLIT_DELIM_CAPTURE);
4947
}
5048
$this->stopwatch = $stopwatch;
5149
$this->fileLinkFormat = $fileLinkFormat;
@@ -268,9 +266,9 @@ private function doDump($data, $name, $file, $line)
268266
$name = strip_tags($this->style('', $name));
269267
$file = strip_tags($this->style('', $file));
270268
if ($fileLinkFormat) {
271-
foreach ($fileLinkFormat[1] as $k => $v) {
272-
if (0 === strpos($file, $k)) {
273-
$file = substr_replace($file, $v, 0, strlen($k));
269+
for ($i = 1; isset($fileLinkFormat[$i]); ++$i) {
270+
if (0 === strpos($file, $k = $fileLinkFormat[$i++])) {
271+
$file = substr_replace($file, $fileLinkFormat[$i], 0, strlen($k));
274272
break;
275273
}
276274
}

0 commit comments

Comments
 (0)