Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit eae54c6

Browse files
[HttpKernel] Set a default file link format when none is provided to FileLinkFormatter
1 parent 8e9ebc4 commit eae54c6

File tree

3 files changed

+7
-2
lines changed

3 files changed

+7
-2
lines changed

src/Symfony/Component/HttpKernel/CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
CHANGELOG
22
=========
33

4+
6.3
5+
---
6+
7+
* Add a default file link format to `FileLinkFormatter` when none is provided
8+
49
6.2
510
---
611

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ class FileLinkFormatter
3535
*/
3636
public function __construct(string|array $fileLinkFormat = null, RequestStack $requestStack = null, string $baseDir = null, string|\Closure $urlFormat = null)
3737
{
38-
$fileLinkFormat ??= $_SERVER['SYMFONY_IDE'] ?? '';
38+
$fileLinkFormat ??= $_SERVER['SYMFONY_IDE'] ?? 'file://%f#L%l';
3939
if (!\is_array($fileLinkFormat) && $fileLinkFormat = (ErrorRendererInterface::IDE_LINK_FORMATS[$fileLinkFormat] ?? $fileLinkFormat) ?: \ini_get('xdebug.file_link_format') ?: get_cfg_var('xdebug.file_link_format') ?: false) {
4040
$i = strpos($f = $fileLinkFormat, '&', max(strrpos($f, '%f'), strrpos($f, '%l'))) ?: \strlen($f);
4141
$fileLinkFormat = [substr($f, 0, $i)] + preg_split('/&([^>]++)>/', substr($f, $i), -1, \PREG_SPLIT_DELIM_CAPTURE);

src/Symfony/Component/HttpKernel/Tests/Debug/FileLinkFormatterTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ public function testAfterUnserialize()
2929
{
3030
$sut = unserialize(serialize(new FileLinkFormatter()));
3131

32-
$this->assertFalse($sut->format('/kernel/root/src/my/very/best/file.php', 3));
32+
$this->assertSame('file:///kernel/root/src/my/very/best/file.php#L3', $sut->format('/kernel/root/src/my/very/best/file.php', 3));
3333
}
3434

3535
public function testWhenFileLinkFormatAndNoRequest()

0 commit comments

Comments
 (0)