Skip to content

Commit 7db4042

Browse files
Simplified link-to-source mapping definitions in debug.file_link_format
1 parent d63247f commit 7db4042

File tree

1 file changed

+5
-7
lines changed

1 file changed

+5
-7
lines changed

Templating/Helper/CodeHelper.php

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,8 @@ public function __construct($fileLinkFormat, $rootDir, $charset)
3535
{
3636
$fileLinkFormat = $fileLinkFormat ?: ini_get('xdebug.file_link_format') ?: get_cfg_var('xdebug.file_link_format');
3737
if ($fileLinkFormat && !is_array($fileLinkFormat)) {
38-
$i = max(strpos($fileLinkFormat, '%f'), strpos($fileLinkFormat, '%l'));
39-
$i = strpos($fileLinkFormat, '#"', $i) ?: strlen($fileLinkFormat);
40-
$fileLinkFormat = array(substr($fileLinkFormat, 0, $i), substr($fileLinkFormat, $i + 1));
41-
$fileLinkFormat[1] = @json_decode('{'.$fileLinkFormat[1].'}', true) ?: array();
38+
$i = strpos($f = $fileLinkFormat, '&', max(strrpos($f, '%f'), strrpos($f, '%l'))) ?: strlen($f);
39+
$fileLinkFormat = array(substr($f, 0, $i)) + preg_split('/&([^>]++)>/', substr($f, $i), -1, PREG_SPLIT_DELIM_CAPTURE);
4240
}
4341
$this->fileLinkFormat = $fileLinkFormat;
4442
$this->rootDir = str_replace('\\', '/', $rootDir).'/';
@@ -193,9 +191,9 @@ public function formatFile($file, $line, $text = null)
193191
public function getFileLink($file, $line)
194192
{
195193
if ($this->fileLinkFormat && is_file($file)) {
196-
foreach ($this->fileLinkFormat[1] as $k => $v) {
197-
if (0 === strpos($file, $k)) {
198-
$file = substr_replace($file, $v, 0, strlen($k));
194+
for ($i = 1; isset($this->fileLinkFormat[$i]); ++$i) {
195+
if (0 === strpos($file, $k = $this->fileLinkFormat[$i++])) {
196+
$file = substr_replace($path, $this->fileLinkFormat[$i], 0, strlen($k));
199197
break;
200198
}
201199
}

0 commit comments

Comments
 (0)