You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm looking at the SymfonyEntrypointProvider and see that it relies on the ServiceMapFactory from phpstan-symfony. This ServiceMapFactory uses the containerXmlPath to function.
In our Symfony project, we have this XML file disabled, because it took 2 seconds to generate.
Our project fully relies on Autowire. So all files in src as scanned, unless they are explicitly marked with the #[Symfony\Component\DependencyInjection\Attribute\Exclude] attribute.
Let's say we would enable the XML file, and configure it as such, I don't think it will answer the question if the class is used or not. Because most of our unused classes, are autowired.
Maybe I'm overlooking something.
The text was updated successfully, but these errors were encountered:
I see your point, but first of all, we do not have "unused class analysis" yet. We only have __construct analysis and that one is definitelly called within your framework. The same assumption is done in VendorEntrypointProvider which marks all overridden methods originating in vendor as used - and that does not need to be true either.
I understand that this is not 100% correct aproach, but at least it allows some decent analysis for some symfony projects. You can always disable those default entrypoint providers and implement some logic yourself. Dead-code analysis is just hard when frameworks come into play :)
If just __construct analysis is not working for you well, you can easily ignore all those errors with single PHPStan ignore regex.
Anyway, thanks for questioning the approach used, we will consider what can be done in future to provide even more precise analysis.
I'm looking at the SymfonyEntrypointProvider and see that it relies on the ServiceMapFactory from phpstan-symfony. This ServiceMapFactory uses the containerXmlPath to function.
In our Symfony project, we have this XML file disabled, because it took 2 seconds to generate.
Our project fully relies on Autowire. So all files in
src
as scanned, unless they are explicitly marked with the#[Symfony\Component\DependencyInjection\Attribute\Exclude]
attribute.Let's say we would enable the XML file, and configure it as such, I don't think it will answer the question if the class is used or not. Because most of our unused classes, are autowired.
Maybe I'm overlooking something.
The text was updated successfully, but these errors were encountered: