You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently the parameter "magento.magentoRoot" is resolved using the variable %currentWorkingDirectory%, which is not necessarily the magento root directory.
(In my case, phpstan is executed by GrumPHP, which runs in completely different directory)
This results in a broken autoloading of classes in some edge cases (e.g. the recently fixed #249):
See bitExpert\PHPStan\Magento\Autoload\DataProvider\ClassLoaderProvider::__construct:
$this->composer = newClassLoader($magentoRoot . '/vendor'); // this directory does not exist$autoloadFile = $magentoRoot . '/vendor/composer/autoload_namespaces.php';
if (is_file($autoloadFile)) { // this check will also fail$map = require$autoloadFile;
foreach ($mapas$namespace => $path) {
$this->composer->set($namespace, $path);
}
}
A workaround is to set the parameter "magento.magentoRoot" not based on the current working directory:
What you experience is what I would call "expected behavior". By default we assume you are installing and invoking phpstan from the magento root directory (the directory that contains the composer.json file). If this is not the case, you need to set the magentoRoot parameter as you described it.
I guess this needs to be clarified in the documentation. Or is there any other behavior that you would expect? Of course, ideally, we could automatically detect the path but I felt that would be rather complex and error-prone. That's why the parameter was introduced.
If the assumption is that the invocation is always in the magento root, than that is okay and makes sense.
A variable which contains the directory of the used configuration file would be nice, but that is a issue/PR for phpstan itself.
Currently the parameter "magento.magentoRoot" is resolved using the variable
%currentWorkingDirectory%
, which is not necessarily the magento root directory.(In my case, phpstan is executed by GrumPHP, which runs in completely different directory)
This results in a broken autoloading of classes in some edge cases (e.g. the recently fixed #249):
See
bitExpert\PHPStan\Magento\Autoload\DataProvider\ClassLoaderProvider::__construct
:A workaround is to set the parameter "magento.magentoRoot" not based on the current working directory:
This resolves to
<vendor>/phpstan/phpstan/../../../
The text was updated successfully, but these errors were encountered: