-
-
Notifications
You must be signed in to change notification settings - Fork 9.7k
Description
Symfony version(s) affected: > v5.3.4
Description
There is a breaking change since DependencyInjection was updated (patch version !). It works fine from v5.0.0 to v5.3.4 but newer versions have a breaking change with decorated services. It seems it was introduced #42815 because of the pass order.
How to reproduce
<?php
namespace Test;
require_once 'vendor/autoload.php';
$containerBuilder = new \Symfony\Component\DependencyInjection\ContainerBuilder();
class Foo {}
class Bar extends Foo {}
class A {
public function __construct(Foo $foo) {}
}
$containerBuilder->register('foo', Foo::class);
$containerBuilder->register('bar', Bar::class)->setDecoratedService('foo');
$containerBuilder->setAlias(Foo::class, 'bar.inner');
$containerBuilder->register(A::class)->setAutowired(true);
$containerBuilder->compile();
This code works for versions <= v5.3.4 and is breaking for versions > v5.3.4.
Error: PHP Fatal error: Uncaught Symfony\Component\DependencyInjection\Exception\ServiceNotFoundException: You have requested a non-existent service "bar.inner". in /.../vendor/symfony/dependency-injection/ContainerBuilder.php:979
Possible Solution
Change the pass order that was changed in #42815 (but if I follow correctly it was made to fix #42791 which was made to fix #42347 because autowire arguments were changed in #40406).