Skip to content

Commit 04dc168

Browse files
committed
Read SYMFONY_IDE to render exception in case of fatal error
1 parent 8e8207b commit 04dc168

File tree

3 files changed

+18
-1
lines changed

3 files changed

+18
-1
lines changed

src/Symfony/Component/ErrorHandler/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+
* Add variable `SYMFONY_IDE` to configure file link format.
89

910
5.4
1011
---

src/Symfony/Component/ErrorHandler/ErrorRenderer/HtmlErrorRenderer.php

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,16 @@
2323
*/
2424
class HtmlErrorRenderer implements ErrorRendererInterface
2525
{
26+
private const FORMATS = [
27+
'textmate' => 'txmt://open?url=file://%f&line=%l',
28+
'macvim' => 'mvim://open?url=file://%f&line=%l',
29+
'emacs' => 'emacs://open?url=file://%f&line=%l',
30+
'sublime' => 'subl://open?url=file://%f&line=%l',
31+
'phpstorm' => 'phpstorm://open?file=%f&line=%l',
32+
'atom' => 'atom://core/open/file?filename=%f&line=%l',
33+
'vscode' => 'vscode://file/%f:%l',
34+
];
35+
2636
private const GHOST_ADDONS = [
2737
'02-14' => self::GHOST_HEART,
2838
'02-29' => self::GHOST_PLUS,
@@ -50,7 +60,10 @@ public function __construct(bool|callable $debug = false, string $charset = null
5060
{
5161
$this->debug = \is_bool($debug) ? $debug : $debug(...);
5262
$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'));
63+
if (null === $fileLinkFormat) {
64+
$fileLinkFormat = $_SERVER['SYMFONY_IDE'] ?? null;
65+
}
66+
$this->fileLinkFormat = (self::FORMATS[$fileLinkFormat] ?? $fileLinkFormat) ?: ini_get('xdebug.file_link_format') ?: get_cfg_var('xdebug.file_link_format') ?: false;
5467
$this->projectDir = $projectDir;
5568
$this->outputBuffer = \is_string($outputBuffer) ? $outputBuffer : $outputBuffer(...);
5669
$this->logger = $logger;

src/Symfony/Component/HttpKernel/Debug/FileLinkFormatter.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,9 @@ class FileLinkFormatter
4444
*/
4545
public function __construct(string $fileLinkFormat = null, RequestStack $requestStack = null, string $baseDir = null, string|\Closure $urlFormat = null)
4646
{
47+
if (null === $fileLinkFormat) {
48+
$fileLinkFormat = $_SERVER['SYMFONY_IDE'] ?? null;
49+
}
4750
$fileLinkFormat = (self::FORMATS[$fileLinkFormat] ?? $fileLinkFormat) ?: ini_get('xdebug.file_link_format') ?: get_cfg_var('xdebug.file_link_format') ?: false;
4851
if ($fileLinkFormat && !\is_array($fileLinkFormat)) {
4952
$i = strpos($f = $fileLinkFormat, '&', max(strrpos($f, '%f'), strrpos($f, '%l'))) ?: \strlen($f);

0 commit comments

Comments
 (0)