bug(finalize-classes): Symfony lazy loading
Hi there,
today I ran finalize-classes on my Symfony Services. Some of my classes are tagged as lazy via Attribute notation:
#[Autoconfigure(lazy: true)]
#[AutoconfigureTag(name: 'app.ran.vendor.huawei.api.client', attributes: ['key' => ApiName::HuaweiMmlCmd->value])]
class MaeMmlApi extends AbstractMaeApi
{...
Finalizing these classes won't work, because Symfony is extending a proxy class with those lazy tagged services.
Can those lazy tagged classes be excluded somehow?
Hey, thanks for repotting.
What is the minimal reproducer? Seems the 2nd attribute is redundant.
Can you send PR with failing test fixture to add it here?
Hey,
I've never contributed to an opensource project or written any tests (kind of a noob here, sorry). Could you elaborate a bit?
Symfony offers quite a few ways to mark a service as lazy (in the class directly via attributes or in the service.yaml configuration): https://symfony.com/doc/current/service_container/lazy_services.html#configuration
Al those cases cannot be finalized, as stated in the Symfony docs: Lazy services do not support final or readonly classes, but you can use Interface Proxifying to work around this limitation.
Hey, sure. No time like first time.
Basically:
- add a line here to link test file with
false(as it should be skipped) https://github.com/rectorphp/swiss-knife/blob/main/tests/NeedsFinalizeAnalyzer/NeedsFinalizeAnalyzerTest.php#L37 - add your file to
Fixturedirectory - https://github.com/rectorphp/swiss-knife/tree/main/tests/NeedsFinalizeAnalyzer/Fixture