Closed shochdoerfer closed 2 years ago
Maybe it will be possible to migrate the whole autoloader magic to PHPStan's BetterReflection\SourceLocator implementation.
For reference, this is the issue I opened in the phpstan repo: https://github.com/phpstan/phpstan/issues/7293
Current plan: Refactor the autoloaders. Get rid of the cache and remove the laminas-code dependency in the extension attribute & extension interface autoloaders as those also seem to cause issues with the BetterReflection reflection logic used by PHPStan 1.7.
It seems important to make the autoloader implementations as dump as possible and as independent as possible. All dependencies need to be injected and not instantiated manually as this causes a problem with laminas-code.
This is a lot more complicated than expected. After removing the cache and the laminas-code dependency, I got stuck with a problem in the ExtensionAttributeDataProvider
. The BetterReflection autoloader magic in PHPStan does not allow the instantiation of new objects (I assume unknown classes - as in not already loaded classes).
Hitting a dead-end road with this. Need to look for alternatives how to hook into PHPStan.
Eval()ing code in the autoloaders also does not work, an error I get now is Interface "Magento\Framework\Api\ExtensionAttributesInterface" not found in file
. I don't see a way to dynamically load classes that don't exist anymore.
Problem fixed in PHPStan core 1.7.2.
The upgrade is currently blocked by an issue with
bitExpert\PHPStan\Magento\Autoload\Cache\FileCacheStorage
where mkdir() seems to fail to create the needed directory structure.