Description
Symfony version(s) affected: 5.1.8
Description
Duplicates #30571 in a certain way (but that's closed)
Exception:
PHP Fatal error: Method class@anonymous::__toString() must not throw an exception
When the Exception AutowiringFailedException is constructed with a callback as message and xdebug is installed in version >= 3.0 the condition which resolves the message callback to the actual message string does not work.
Xdebug 3.0 does not provide the function xdebug_is_enabled
anymore. See https://xdebug.org/docs/upgrade_guide#Changes-to-Functions
How to reproduce
You can use the reproducer from #30571. Please ensure your environment has Xdebug 3.0 installed.
Possible Solution
Replace \function_exists('xdebug_is_enabled') && xdebug_is_enabled()
in AutowiringFailedException.php:26 with a condition which is true for xdebug 2.x and 3.x.
Additional context
Exception call stack:
(Hint: The mentioned class@anonymous::__toString()
is defined in symfony/dependency-injection/Exception/AutowiringFailedException.php:39 and following)
PHP Fatal error: Method class@anonymous::__toString() must not throw an exception, caught Symfony\Component\DependencyInjection\Exception\AutowiringFailedException: in /app/app/vendor/symfony/dependency-injection/Compiler/AutowirePass.php on line 236
PHP Stack trace:
PHP 1. {main}() /app/app/bin/console:0
PHP 2. Symfony\Bundle\FrameworkBundle\Console\Application->run() /app/app/bin/console:42
PHP 3. Symfony\Bundle\FrameworkBundle\Console\Application->doRun() /app/app/vendor/symfony/console/Application.php:142
PHP 4. Symfony\Bundle\FrameworkBundle\Console\Application->registerCommands() /app/app/vendor/symfony/framework-bundle/Console/Application.php:74
PHP 5. App\Kernel->boot() /app/app/vendor/symfony/framework-bundle/Console/Application.php:168
PHP 6. App\Kernel->initializeContainer() /app/app/vendor/symfony/http-kernel/Kernel.php:131
PHP 7. Symfony\Component\DependencyInjection\ContainerBuilder->compile() /app/app/vendor/symfony/http-kernel/Kernel.php:533
PHP 8. Symfony\Component\DependencyInjection\Compiler\Compiler->compile() /app/app/vendor/symfony/dependency-injection/ContainerBuilder.php:736
PHP 9. Symfony\Component\DependencyInjection\Compiler\AutowirePass->process() /app/app/vendor/symfony/dependency-injection/Compiler/Compiler.php:91
PHP 10. Symfony\Component\DependencyInjection\Compiler\AutowirePass->process() /app/app/vendor/symfony/dependency-injection/Compiler/AutowirePass.php:54
PHP 11. Symfony\Component\DependencyInjection\Compiler\AutowirePass->processValue() /app/app/vendor/symfony/dependency-injection/Compiler/AbstractRecursivePass.php:46
PHP 12. Symfony\Component\DependencyInjection\Compiler\AutowirePass->doProcessValue() /app/app/vendor/symfony/dependency-injection/Compiler/AutowirePass.php:72
PHP 13. Symfony\Component\DependencyInjection\Compiler\AutowirePass->processValue() /app/app/vendor/symfony/dependency-injection/Compiler/AutowirePass.php:103
PHP 14. Symfony\Component\DependencyInjection\Compiler\AutowirePass->processValue() /app/app/vendor/symfony/dependency-injection/Compiler/AbstractRecursivePass.php:81
PHP 15. Symfony\Component\DependencyInjection\Compiler\AutowirePass->doProcessValue() /app/app/vendor/symfony/dependency-injection/Compiler/AutowirePass.php:72
PHP 16. Symfony\Component\DependencyInjection\Compiler\AutowirePass->autowireCalls() /app/app/vendor/symfony/dependency-injection/Compiler/AutowirePass.php:126
PHP 17. Symfony\Component\DependencyInjection\Compiler\AutowirePass->autowireMethod() /app/app/vendor/symfony/dependency-injection/Compiler/AutowirePass.php:171
PHP 18. Symfony\Component\DependencyInjection\Compiler\AutowirePass->Symfony\Component\DependencyInjection\Compiler\{closure:/app/app/vendor/symfony/dependency-injection/Compiler/AutowirePass.php:229-241}() /app/app/vendor/symfony/dependency-injection/Compiler/AutowirePass.php:261