Closed
Description
Symfony version(s) affected
6.2.0
Description
When trying, you get the following exception:
Symfony\Component\DependencyInjection\Exception\InvalidArgumentException
: Cannot generate lazy proxy for service "App\Wrapper.inner".Symfony\Component\VarExporter\Exception\LogicException
: Cannot generate lazy proxy: class "App\Implementation" is final.
How to reproduce
Reproducer: https://github.com/kbond/symfony-reproducer/tree/decorated-lazy-service
interface Contract
{
}
#[Autoconfigure(lazy: Contract::class)]
final class Implementation implements Contract
{
}
#[AsDecorator(decorates: Implementation::class)]
final class Wrapper implements Contract
{
public function __construct(private Contract $inner)
{
}
}
Then inject Implementation
somewhere.
Possible Solution
Removing final
from the decorated class (Implementation
above) solves the issue but this is not ideal.
Additional Context
No response