deprecated-packages / reveal-src

Static analysis for your templates is here!
9 stars 3 forks source link

`reveal/reveal-latte` causes PHPStan analyse to fail #12

Closed ZebulanStanphill closed 2 years ago

ZebulanStanphill commented 2 years ago

With reveal/reveal-latte installed, phpstan analyse will fail and output the following error as long as the Reveal\RevealLatte\Rules\LatteCompleteCheckRule rule is included in my PHPStan config:

In Container.php line 156:
  Circular reference detected for services: 038, 039, 028, registry, 0367, 0538.

This rather cryptic error appears to have something to do with the Container class from nette/component-model, but the reported line doesn't appear to be anything relevant in the latest released version (3.0.2, which I've verified is the one installed in my vendor folder).

It kinda seems like LatteCompleteCheckRule is just broken in the current version of reveal/reveal-latte (0.1.1). Maybe it has something to do with me using PHP 8.1?

Here is a simple repo that I used to reproduce the issue: https://gitlab.com/ZebulanStanphill/reveal-latte-bug-reproduction

In fact, even reducing the PHP code to just an empty Main.php (and deleting the Latte file) still doesn't make the error go away. The code that's there is mostly just for the sake of demonstrating the kind of code I'd want to lint in one of my real projects.

lulco commented 2 years ago

Reveal\RevealLatte\Rules\LatteCompleteCheckRule is registered twice - check generated container in /tmp/phpstan/cache/nette.configurator/Container_something.php

You will see something like this:

'Reveal\RevealLatte\Rules\LatteCompleteCheckRule' => [['0359', '0486']],

First it is registered via phpstan/extension-installer and second is manually in phpstan.dist.neon

ZebulanStanphill commented 2 years ago

Oh, sorry. I didn't realize that explicitly registering it in my config would cause issues if it was already being auto-registered. Thanks for your help!