phpstan / phpstan

PHP Static Analysis Tool - discover bugs in your code without running it!
https://phpstan.org/
MIT License
12.82k stars 866 forks source link

installed.json needed since 0.12.4 #2818

Closed mitelg closed 4 years ago

mitelg commented 4 years ago

Bug report

In FileReader.php line 13: [PHPStan\File\CouldNotReadFileException] Could not read file: www/development/custom/plugins/paypal/vendor/composer/installed.json

Exception trace: at phar://www/development/dev-ops/analyze/vendor-bin/phpstan/vendor/phpstan/phpstan/phpstan/src/File/FileReader.php:13 PHPStan\File\FileReader::read() at phar://www/development/dev-ops/analyze/vendor-bin/phpstan/vendor/phpstan/phpstan/phpstan/src/Reflection/BetterReflection/SourceLocator/ComposerJsonAndInstalledJsonSourceLocatorMaker.php:35 PHPStan\Reflection\BetterReflection\SourceLocator\ComposerJsonAndInstalledJsonSourceLocatorMaker->create() at phar://www/development/dev-ops/analyze/vendor-bin/phpstan/vendor/phpstan/phpstan/phpstan/src/Reflection/BetterReflection/BetterReflectionSourceLocatorFactory.php:70 PHPStan\Reflection\BetterReflection\BetterReflectionSourceLocatorFactory->create() at /tmp/phpstan/cache/nette.configurator/Container_d6d6ac9150.php:3885 Container_d6d6ac9150->createServiceBetterReflectionSourceLocator() at phar://www/development/dev-ops/analyze/vendor-bin/phpstan/vendor/phpstan/phpstan/phpstan/vendor/nette/di/src/DI/Container.php:146 _HumbugBoxa750b42bd25b\Nette\DI\Container->createService() at phar://www/development/dev-ops/analyze/vendor-bin/phpstan/vendor/phpstan/phpstan/phpstan/vendor/nette/di/src/DI/Container.php:88 _HumbugBoxa750b42bd25b\Nette\DI\Container->getService() at /tmp/phpstan/cache/nette.configurator/Container_d6d6ac9150.php:3841 Container_d6d6ac9150->createServiceBetterReflectionClassReflector() at phar://www/development/dev-ops/analyze/vendor-bin/phpstan/vendor/phpstan/phpstan/phpstan/vendor/nette/di/src/DI/Container.php:146 _HumbugBoxa750b42bd25b\Nette\DI\Container->createService() at phar://www/development/dev-ops/analyze/vendor-bin/phpstan/vendor/phpstan/phpstan/phpstan/vendor/nette/di/src/DI/Container.php:88 _HumbugBoxa750b42bd25b\Nette\DI\Container->getService() at /tmp/phpstan/cache/nette.configurator/Container_d6d6ac9150.php:3867 Container_d6d6ac9150->createServiceBetterReflectionProvider() at phar://www/development/dev-ops/analyze/vendor-bin/phpstan/vendor/phpstan/phpstan/phpstan/vendor/nette/di/src/DI/Container.php:146 _HumbugBoxa750b42bd25b\Nette\DI\Container->createService() at phar://www/development/dev-ops/analyze/vendor-bin/phpstan/vendor/phpstan/phpstan/phpstan/vendor/nette/di/src/DI/Container.php:88 _HumbugBoxa750b42bd25b\Nette\DI\Container->getService() at /tmp/phpstan/cache/nette.configurator/Container_d6d6ac9150.php:3976 Container_d6d6ac9150->createServicePhpParserReflectionProvider() at phar://www/development/dev-ops/analyze/vendor-bin/phpstan/vendor/phpstan/phpstan/phpstan/vendor/nette/di/src/DI/Container.php:146 _HumbugBoxa750b42bd25b\Nette\DI\Container->createService() at phar://www/development/dev-ops/analyze/vendor-bin/phpstan/vendor/phpstan/phpstan/phpstan/vendor/nette/di/src/DI/Container.php:88 _HumbugBoxa750b42bd25b\Nette\DI\Container->getService() at /tmp/phpstan/cache/nette.configurator/Container_d6d6ac9150.php:3995 Container_d6d6ac9150->createServiceReflectionProviderFactory() at phar://www/development/dev-ops/analyze/vendor-bin/phpstan/vendor/phpstan/phpstan/phpstan/vendor/nette/di/src/DI/Container.php:146 _HumbugBoxa750b42bd25b\Nette\DI\Container->createService() at phar://www/development/dev-ops/analyze/vendor-bin/phpstan/vendor/phpstan/phpstan/phpstan/vendor/nette/di/src/DI/Container.php:88 _HumbugBoxa750b42bd25b\Nette\DI\Container->getService() at /tmp/phpstan/cache/nette.configurator/Container_d6d6ac9150.php:3984 Container_d6d6ac9150->createServiceReflectionProvider() at phar://www/development/dev-ops/analyze/vendor-bin/phpstan/vendor/phpstan/phpstan/phpstan/vendor/nette/di/src/DI/Container.php:146 _HumbugBoxa750b42bd25b\Nette\DI\Container->createService() at phar://www/development/dev-ops/analyze/vendor-bin/phpstan/vendor/phpstan/phpstan/phpstan/vendor/nette/di/src/DI/Container.php:88 _HumbugBoxa750b42bd25b\Nette\DI\Container->getService() at phar://www/development/dev-ops/analyze/vendor-bin/phpstan/vendor/phpstan/phpstan/phpstan/vendor/nette/di/src/DI/Container.php:166 _HumbugBoxa750b42bd25b\Nette\DI\Container->getByType() at phar://www/development/dev-ops/analyze/vendor-bin/phpstan/vendor/phpstan/phpstan/phpstan/src/DependencyInjection/Nette/NetteContainer.php:36 PHPStan\DependencyInjection\Nette\NetteContainer->getByType() at phar://www/development/dev-ops/analyze/vendor-bin/phpstan/vendor/phpstan/phpstan/phpstan/src/Broker/BrokerFactory.php:26 PHPStan\Broker\BrokerFactory->create() at /tmp/phpstan/cache/nette.configurator/Container_d6d6ac9150.php:3891 Container_d6d6ac9150->createServiceBroker() at phar://www/development/dev-ops/analyze/vendor-bin/phpstan/vendor/phpstan/phpstan/phpstan/vendor/nette/di/src/DI/Container.php:146 _HumbugBoxa750b42bd25b\Nette\DI\Container->createService() at phar://www/development/dev-ops/analyze/vendor-bin/phpstan/vendor/phpstan/phpstan/phpstan/vendor/nette/di/src/DI/Container.php:88 _HumbugBoxa750b42bd25b\Nette\DI\Container->getService() at phar://www/development/dev-ops/analyze/vendor-bin/phpstan/vendor/phpstan/phpstan/phpstan/vendor/nette/di/src/DI/Container.php:166 _HumbugBoxa750b42bd25b\Nette\DI\Container->getByType() at phar://www/development/dev-ops/analyze/vendor-bin/phpstan/vendor/phpstan/phpstan/phpstan/src/DependencyInjection/ContainerFactory.php:56 PHPStan\DependencyInjection\ContainerFactory->create() at phar://www/development/dev-ops/analyze/vendor-bin/phpstan/vendor/phpstan/phpstan/phpstan/src/Command/CommandHelper.php:171 PHPStan\Command\CommandHelper::begin() at phar://www/development/dev-ops/analyze/vendor-bin/phpstan/vendor/phpstan/phpstan/phpstan/src/Command/AnalyseCommand.php:61 PHPStan\Command\AnalyseCommand->execute() at phar://www/development/dev-ops/analyze/vendor-bin/phpstan/vendor/phpstan/phpstan/phpstan/vendor/symfony/console/Command/Command.php:228 _HumbugBoxa750b42bd25b\Symfony\Component\Console\Command\Command->run() at phar://www/development/dev-ops/analyze/vendor-bin/phpstan/vendor/phpstan/phpstan/phpstan/vendor/symfony/console/Application.php:858 _HumbugBoxa750b42bd25b\Symfony\Component\Console\Application->doRunCommand() at phar://www/development/dev-ops/analyze/vendor-bin/phpstan/vendor/phpstan/phpstan/phpstan/vendor/symfony/console/Application.php:236 _HumbugBoxa750b42bd25b\Symfony\Component\Console\Application->doRun() at phar://www/development/dev-ops/analyze/vendor-bin/phpstan/vendor/phpstan/phpstan/phpstan/vendor/symfony/console/Application.php:137 _HumbugBoxa750b42bd25b\Symfony\Component\Console\Application->run() at phar://www/development/dev-ops/analyze/vendor-bin/phpstan/vendor/phpstan/phpstan/phpstan/bin/phpstan:70 _HumbugBoxa750b42bd25b{closure}() at phar://www/development/dev-ops/analyze/vendor-bin/phpstan/vendor/phpstan/phpstan/phpstan/bin/phpstan:71 require() at www/development/dev-ops/analyze/vendor-bin/phpstan/vendor/phpstan/phpstan/phpstan:6

Expected output

Is the installed.json really needed? It wasn't before, so maybe there is a way to do the analysis without executing composer install in the plugin directory :blush:

mergeable[bot] commented 4 years ago

This bug report is missing a link to reproduction on phpstan.org. It will most likely be closed after manual review.

ondrejmirtes commented 4 years ago

Hi, how is it possible that this file is missing from your Composer installation? I can work around it but I thought it's a given this file will always be there.

mitelg commented 4 years ago

We have a development template which is the project root. it also contains the platform repo mentioned above. Here is the main vendor directory located, which also contains the installed.json file. (here happend the composer install)

My plugin is located in a directory here. I execute PHPStan in the plugin directory. Before executing I do a composer dump-autoload otherwise PHPStan could not load the classes of the plugin correctly. I also have to configure the --autoload-file option, which shows to the mentioned above main vendor directory, to load the Shopware Core classes correctly, that are also used in the plugin.

I hope this makes it a bit clearer. If not, I'm willing to explain it more detailed :blush:

ondrejmirtes commented 4 years ago

Thank you for the explanation. I just fixed it: https://github.com/phpstan/phpstan-src/commit/e4fe64c8444cd19c863327ba292055cacb54acd1

Please try out phpstan/phpstan dev-master in half an hour or so when the change propagates.

mitelg commented 4 years ago

works again very well! :+1: thank you!

lock[bot] commented 4 years ago

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.