1
0
mirror of https://github.com/maximebf/php-debugbar.git synced 2025-07-28 04:00:43 +02:00

Remove xdebug replacements on previews (#542)

This commit is contained in:
erikn69
2023-09-19 10:03:05 -05:00
committed by GitHub
parent 1b1419202f
commit ec7d1ae890
2 changed files with 27 additions and 1 deletions

View File

@@ -74,6 +74,32 @@ abstract class DataCollector implements DataCollectorInterface
return $this->dataFormater;
}
/**
* Shorten the file path by removing the xdebug path replacements
*
* @param string $file
* @return string
*/
public function normalizeFilePath($file)
{
if (empty($file)) {
return '';
}
if (file_exists($file)) {
$file = realpath($file);
}
foreach (array_keys($this->xdebugReplacements) as $path) {
if (strpos($file, $path) === 0) {
$file = substr($file, strlen($path));
break;
}
}
return ltrim(str_replace('\\', '/', $file), '/');
}
/**
* Get an Xdebug Link to a file
*

View File

@@ -139,7 +139,7 @@ class ExceptionsCollector extends DataCollector implements Renderable
'type' => get_class($e),
'message' => $e->getMessage(),
'code' => $e->getCode(),
'file' => $filePath,
'file' => $this->normalizeFilePath($filePath),
'line' => $e->getLine(),
'stack_trace' => $e->getTraceAsString(),
'stack_trace_html' => $traceHtml,