Description
Currently, the extension is unaware of usage in templates (like Twig).
I'm working on TwigStan. TwigStan is a separate tool that invokes PHPStan (it's not an extension). It compiles Twig templates to PHP and then cleans them up. It then executes PHPStan.
I was thinking: if TwigStan runs PHPStan with dead-code-detector extension enabled, we could export the MethodCallCollector to a JSON file. This data has all the method calls from the Twig templates to entities / methods.
Then, when normally running PHPStan on the whole project, we could include the data from JSON with the other MethodCallCollector.
Now, dead-code-detector has a full picture about calls in PHP and in Twig.
The downside of this approach is obviously that the dead-code-detector extension has a dependency on the TwigStan run.
But I think it could be fine to only run dead-code-detector on CI, after TwigStan was completed.