Description
Symfony version(s) affected
6.0
Description
With this change in 6.0, the previously untyped FileLinkFormatter::$fileLinkFormat
property now does not support strings anymore. As the default value of the constructor parameter $fileLinkFormat
is null
and FileLinkFormatter::FORMATS
does not have an entry for null
, after this line
$fileLinkFormat
will be an empty string if xdebug.file_link_format
is empty, which appears to be its default value. Thus,
symfony/src/Symfony/Component/HttpKernel/Debug/FileLinkFormatter.php
Lines 48 to 51 in d54ef8c
is never entered and
throws a TypeError
because a string
is assigned to an array|false
variable.
How to reproduce
- Setup PHP with an empty
xdebug.file_link_format
value:
$ php -i | grep xdebug.file_link_format
xdebug.file_link_format => no value => no value
- Install symfony with
webapp
(as instructed in the documentation):
composer create-project symfony/skeleton . 6.0.99 && composer require webapp
(I added the explicit version number because I was also testing previous versions where the issue did not occur.)
- You get the following exception:
!! TypeError {#4981
!! #message: "Cannot assign string to property Symfony\Component\HttpKernel\Debug\FileLinkFormatter::$fileLinkFormat of type array|false"
!! #code: 0
!! #file: "./vendor/symfony/http-kernel/Debug/FileLinkFormatter.php"
!! #line: 53
!! trace: {
!! ./vendor/symfony/http-kernel/Debug/FileLinkFormatter.php:53 { …}
!! ./var/cache/dev/ContainerQqKtafO/App_KernelDevDebugContainer.php:1236 {
!! ContainerQqKtafO\App_KernelDevDebugContainer->getDebug_FileLinkFormatterService()
!! › return ($this->privates['debug.file_link_formatter.url_format'] ?? $this->load('getDebug_FileLinkFormatter_UrlFormatService'));
!! › });
!! › }
!! }
!! ./var/cache/dev/ContainerQqKtafO/getVarDumper_ContextualizedCliDumper_InnerService.php:22 { …}
!! ./var/cache/dev/ContainerQqKtafO/App_KernelDevDebugContainer.php:429 { …}
!! ./var/cache/dev/ContainerQqKtafO/getDebug_DumpListenerService.php:23 { …}
!! ./var/cache/dev/ContainerQqKtafO/App_KernelDevDebugContainer.php:429 { …}
!! ./var/cache/dev/ContainerQqKtafO/App_KernelDevDebugContainer.php:825 { …}
!! ./vendor/symfony/event-dispatcher/EventDispatcher.php:245 { …}
!! ./vendor/symfony/event-dispatcher/EventDispatcher.php:76 { …}
!! ./vendor/symfony/event-dispatcher/Debug/TraceableEventDispatcher.php:283 { …}
!! ./vendor/symfony/event-dispatcher/Debug/TraceableEventDispatcher.php:146 { …}
!! ./vendor/symfony/console/Application.php:1004 { …}
!! ./vendor/symfony/framework-bundle/Console/Application.php:94 { …}
!! ./vendor/symfony/console/Application.php:299 { …}
!! ./vendor/symfony/framework-bundle/Console/Application.php:80 { …}
!! ./vendor/symfony/console/Application.php:171 { …}
!! ./vendor/symfony/runtime/Runner/Symfony/ConsoleApplicationRunner.php:54 { …}
!! ./vendor/autoload_runtime.php:29 { …}
!! ./bin/console:11 { …}
!! }
!! }
Possible Solution
Properly handle the case of $fileLinkFormat
being an empty string by setting FileLinkFormatter::$fileLinkFormat
to false.
Additional Context
No response