Closed
Description
Symfony version(s) affected
6.4.3
Description
marking any readonly
class as a lazy service results in an error.
the bug seems not on symfony side, but on (#53843 (comment))
https://github.com/FriendsOfPHP/proxy-manager-lts
side, as it does not count for readonly classes while creating proxies.
How to reproduce
- create
readonly
class
<?php
namespace App;
readonly class TestService
{
public function foo(): string
{
return 'bar';
}
}
- mark it as lazy
services:
App\TestService:
lazy: true
- inject it anywhere, e.g. in controller
<?php
namespace App\Controller;
use App\TestService;
use Symfony\Component\Routing\Attribute\Route;
class TestController
{
#[Route(path: '/test')
public function __invoke(TestService $service): Response
{
return new Response($service->foo());
}
}
- result is error
Compile Error: Non-readonly class ContainerBh60GB2\TestServiceGhost93bb697 cannot extend readonly class App\TestService
Possible Solution
No response
Additional Context
No response