Open dmanners opened 4 months ago
Thanks for reporting the issue @dmanners.
The difference between local and CI runs is that locally, PHPStan and this extension will most likely use the Magento-generated classes (if they exist), while in CI, the PHPStan extension generates the missing classes by itself with its own logic. Still, that does not explain why CI occasionally breaks.
Yeah it's odd some runs it's fine and some the errors appear but on a rerun everything is then green. I have also tested it locally without a generated folder and it's still green locally. I will also check that we dont override a magento file with a local patch that isnt applied in the pipeline as well.
I have also tested out firstly clearing the phpstan cache folder before running the check.
Ok after a bit more debugging I have found that disabling the parallel processing then the errors do not seem to appear.
parallel:
maximumNumberOfProcesses: 1
Here I have run our pipeline 3 times and had no error cases.
Uh, good catch! Fixing this issue might not be easy due to the way the autoloader & the code generation in this extension work. Will think about it.
I will keep this updated after a week or so of pipeline runs to see if this setting helps us in the long run or just randomly today.
Sounds like a plan. Don't close the issue if the current setting works for you. I'll take this as an opportunity to discuss with Ondrej how to better hook into PHPStan to generate the classes when they do not exist. The autoloader magic isn't ideal and seems to break a few things, e.g. the Rector integration (see #297). Looks like a larger refactoring is needed to improve things.
If the setting does work for you, please consider adding a PR to the README that includes a hint on how to resolve the issue.
Yeah this seems to have fixed the issue with us a week of pipeline runs and no false positive errors in the phpstan job.
While running phpstan in the context of our Magento project locally we get no errors, but occasionally with the same code base running in a ci/cd pipeline we will get errors that will either change or disappear on a re-run.
The errors that do appear seem to only occur with extension attributes.
In our pipeline and also lokally we are running
With the config
I have tried clearing the phpstan cache both locally and in the pipeline as well as locally clearing the generated folder as in the pipeline we have no generated folder.