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:
@@ -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
|
||||
*
|
||||
|
@@ -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,
|
||||
|
Reference in New Issue
Block a user