Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit58c831b

Browse files
committed
[ErrorHandler] Improve fileLinkFormat handling (#50619)
- Avoid repeating file link format guessing (logic is already in FileLinkFormatter class)- Always set a fileLinkFormat to a FileLinkFormatter object to handle path mappings properly
1 parente0cb460 commit58c831b

File tree

2 files changed

+47
-4
lines changed

2 files changed

+47
-4
lines changed

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,10 +52,10 @@ public function __construct(bool|callable $debug = false, string $charset = null
5252
{
5353
$this->debug =\is_bool($debug) ?$debug :$debug(...);
5454
$this->charset =$charset ?: (\ini_get('default_charset') ?:'UTF-8');
55-
$fileLinkFormat??=$_ENV['SYMFONY_IDE'] ??$_SERVER['SYMFONY_IDE'] ??null;
56-
$this->fileLinkFormat =\is_string($fileLinkFormat)
57-
? (ErrorRendererInterface::IDE_LINK_FORMATS[$fileLinkFormat] ??$fileLinkFormat ?:false)
58-
: ($fileLinkFormat ?:\ini_get('xdebug.file_link_format') ?:get_cfg_var('xdebug.file_link_format') ?:false);
55+
$this->fileLinkFormat=\is_string($fileLinkFormat) ?newFileLinkFormatter($fileLinkFormat) : ($fileLinkFormat ?:false);
56+
if (false ===$this->fileLinkFormat) {
57+
$this->fileLinkFormat =newFileLinkFormatter();
58+
}
5959
$this->projectDir =$projectDir;
6060
$this->outputBuffer =\is_string($outputBuffer) ?$outputBuffer :$outputBuffer(...);
6161
$this->logger =$logger;

‎src/Symfony/Component/ErrorHandler/Tests/ErrorRenderer/HtmlErrorRendererTest.php

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,49 @@ public function testRender(\Throwable $exception, HtmlErrorRenderer $errorRender
2424
$this->assertStringMatchesFormat($expected,$errorRenderer->render($exception)->getAsString());
2525
}
2626

27+
/**
28+
* @dataProvider provideFileLinkFormats
29+
*/
30+
publicfunctiontestFileLinkFormat(\ErrorException$exception,string$fileLinkFormat,bool$withSymfonyIde,string$expected)
31+
{
32+
if ($withSymfonyIde) {
33+
$_ENV['SYMFONY_IDE'] =$fileLinkFormat;
34+
}
35+
$errorRenderer =newHtmlErrorRenderer(true,null,$withSymfonyIde ?null :$fileLinkFormat);
36+
37+
$this->assertStringContainsString($expected,$errorRenderer->render($exception)->getAsString());
38+
}
39+
40+
publicfunctionprovideFileLinkFormats():iterable
41+
{
42+
$exception =new \ErrorException('Notice',0, \E_USER_NOTICE);
43+
44+
yield'file link format set as known IDE with SYMFONY_IDE' => [
45+
$exception,
46+
'vscode',
47+
true,
48+
'href="vscode://file/'.__DIR__
49+
];
50+
yield'file link format set as a raw format with SYMFONY_IDE' => [
51+
$exception,
52+
'phpstorm://open?file=%f&line=%l',
53+
true,
54+
'href="phpstorm://open?file='.__DIR__
55+
];
56+
yield'file link format set as known IDE without SYMFONY_IDE' => [
57+
$exception,
58+
'vscode',
59+
false,
60+
'href="vscode://file/'.__DIR__
61+
];
62+
yield'file link format set as a raw format without SYMFONY_IDE' => [
63+
$exception,
64+
'phpstorm://open?file=%f&line=%l',
65+
false,
66+
'href="phpstorm://open?file='.__DIR__
67+
];
68+
}
69+
2770
publicstaticfunctiongetRenderData():iterable
2871
{
2972
$expectedDebug =<<<HTML

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp