Skip to content

Commit 48c36d1

Browse files
authored
Fix multiple replacement on the same path (php-debugbar#541)
1 parent ae41159 commit 48c36d1

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

src/DebugBar/DataCollector/DataCollector.php

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,8 +87,15 @@ public function getDataFormatter()
8787
*/
8888
public function getXdebugLink($file, $line = 1)
8989
{
90-
if (count($this->xdebugReplacements)) {
91-
$file = strtr($file, $this->xdebugReplacements);
90+
if (file_exists($file)) {
91+
$file = realpath($file);
92+
}
93+
94+
foreach ($this->xdebugReplacements as $path => $replacement) {
95+
if (strpos($file, $path) === 0) {
96+
$file = $replacement . substr($file, strlen($path));
97+
break;
98+
}
9299
}
93100

94101
$url = strtr($this->getXdebugLinkTemplate(), ['%f' => $file, '%l' => $line]);

0 commit comments

Comments
 (0)