diff --git a/src/Symfony/Component/HttpKernel/Debug/FileLinkFormatter.php b/src/Symfony/Component/HttpKernel/Debug/FileLinkFormatter.php index 2879273005428..fc85efce4ae00 100644 --- a/src/Symfony/Component/HttpKernel/Debug/FileLinkFormatter.php +++ b/src/Symfony/Component/HttpKernel/Debug/FileLinkFormatter.php @@ -35,8 +35,8 @@ class FileLinkFormatter ]; private array|false $fileLinkFormat; - private ?RequestStack $requestStack; - private ?string $baseDir; + private ?RequestStack $requestStack = null; + private ?string $baseDir = null; private \Closure|string|null $urlFormat; /** diff --git a/src/Symfony/Component/HttpKernel/Tests/Debug/FileLinkFormatterTest.php b/src/Symfony/Component/HttpKernel/Tests/Debug/FileLinkFormatterTest.php index 548112ad52fef..35a4e1658eb48 100644 --- a/src/Symfony/Component/HttpKernel/Tests/Debug/FileLinkFormatterTest.php +++ b/src/Symfony/Component/HttpKernel/Tests/Debug/FileLinkFormatterTest.php @@ -25,6 +25,13 @@ public function testWhenNoFileLinkFormatAndNoRequest() $this->assertFalse($sut->format('/kernel/root/src/my/very/best/file.php', 3)); } + public function testAfterUnserialize() + { + $sut = unserialize(serialize(new FileLinkFormatter())); + + $this->assertFalse($sut->format('/kernel/root/src/my/very/best/file.php', 3)); + } + public function testWhenFileLinkFormatAndNoRequest() { $file = __DIR__.\DIRECTORY_SEPARATOR.'file.php';