Best way to dynamically generate missing class information for PHPStan? #10982
Unanswered
shochdoerfer
asked this question in
Support
Replies: 1 comment
-
Hi, I'd say the custom autoloader is the right approach and should not be abandoned. If there are issues with it it should be possible to fix them either right in the autoloader, or in PHPStan. Do you know why the current approach sometimes fail? It should be possible to analyse the situation and find remedies for it. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Context: Magento 2 needs many classes (e.g., factories, proxies, etc.) that are either generated on the fly (e.g., in development mode) or can be generated in a separate build step (for production setups). The code generation logic is part of the developer tools found in a Magento application project and is unavailable if you develop a standalone custom module.
When I started to develop the first version of bitExpert/phpstan-magento extension for PHPStan, the logic consequence was to make use of PHP's class autoloading capabilities and generate the missing classes on the fly when PHPStan cannot find them. Generally, this procedure works fine, but every now and then, we run into issues. For example, there seems to be an issue with Rector and PHPStan when the phpstan-magento extension is active, and recently a problem was identified with the autoloaders when multiple PHPStan processes are run in parallel.
I am now wondering what other options are available to fix these issues and offer a better PHPStan experience. I mainly see two options:
Maybe I am missing other options. Ideally, I don't want the users to run two processes manually (process 1: generate missing classes; process 2: PHPStan), and in my perfect world scenario, I'd like to re-use the PHPStan caching mechanism to speed up the class generation process as much as possible.
What options do I have to improve the whole situation?
Beta Was this translation helpful? Give feedback.
All reactions