Skip to content

Commit 19dbb5d

Browse files
committed
Read SYMFONY_IDE to render exception in case of fatal error
1 parent bc8e8d2 commit 19dbb5d

File tree

3 files changed

+15
-1
lines changed

3 files changed

+15
-1
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ CHANGELOG
55
---
66

77
* Report overridden `@final` constants and properties
8+
* Read environment variable `SYMFONY_IDE` to configure file link format
89

910
5.4
1011
---

ErrorRenderer/ErrorRendererInterface.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,16 @@
2020
*/
2121
interface ErrorRendererInterface
2222
{
23+
public const IDE_LINK_FORMATS = [
24+
'textmate' => 'txmt://open?url=file://%f&line=%l',
25+
'macvim' => 'mvim://open?url=file://%f&line=%l',
26+
'emacs' => 'emacs://open?url=file://%f&line=%l',
27+
'sublime' => 'subl://open?url=file://%f&line=%l',
28+
'phpstorm' => 'phpstorm://open?file=%f&line=%l',
29+
'atom' => 'atom://core/open/file?filename=%f&line=%l',
30+
'vscode' => 'vscode://file/%f:%l',
31+
];
32+
2333
/**
2434
* Renders a Throwable as a FlattenException.
2535
*/

ErrorRenderer/HtmlErrorRenderer.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,10 @@ public function __construct(bool|callable $debug = false, string $charset = null
5050
{
5151
$this->debug = \is_bool($debug) ? $debug : $debug(...);
5252
$this->charset = $charset ?: (ini_get('default_charset') ?: 'UTF-8');
53-
$this->fileLinkFormat = $fileLinkFormat ?: (ini_get('xdebug.file_link_format') ?: get_cfg_var('xdebug.file_link_format'));
53+
$fileLinkFormat ??= $_SERVER['SYMFONY_IDE'] ?? null;
54+
$this->fileLinkFormat = is_string($fileLinkFormat)
55+
? (ErrorRendererInterface::IDE_LINK_FORMATS[$fileLinkFormat] ?? $fileLinkFormat ?: false)
56+
: ($fileLinkFormat ?: ini_get('xdebug.file_link_format') ?: get_cfg_var('xdebug.file_link_format') ?: false);
5457
$this->projectDir = $projectDir;
5558
$this->outputBuffer = \is_string($outputBuffer) ? $outputBuffer : $outputBuffer(...);
5659
$this->logger = $logger;

0 commit comments

Comments
 (0)