mglaman / drupal-check

Check Drupal code for deprecations and discover bugs via static analysis
GNU General Public License v2.0
333 stars 67 forks source link

Global install no longer works in Drupal ^10.0.0 #302

Open Dropa opened 1 year ago

Dropa commented 1 year ago

How is drupal-check installed?

drupal-check is installed globally via Composer

Environment:

Describe the bug

Looks like Drupal 10 comes with additional dependencies that doesn't play nicely along with global installation.

Was able to reproduce as minimal as https://github.com/drupal-composer/drupal-project

Console output

Executing PHPStan

In Resolver.php line 470:

  [_PHPStan_3334735b2\Nette\DI\ServiceCreationException]                       
  Service 'rules.115' (type of mglaman\PHPStanDrupal\Rules\Drupal\RenderCallb  
  ackRule): Multiple services of type mglaman\PHPStanDrupal\Drupal\ServiceMap  
   found: 0344, 0366 (required by $serviceMap in RenderCallbackRule::__constr  
  uct())                                                                       

Exception trace:
  at phar:///home/wodby/.composer/vendor/phpstan/phpstan/phpstan.phar/vendor/nette/di/src/DI/Resolver.php:470
 _PHPStan_3334735b2\Nette\DI\Resolver::autowireArgument() at phar:///home/wodby/.composer/vendor/phpstan/phpstan/phpstan.phar/vendor/nette/di/src/DI/Resolver.php:422
 _PHPStan_3334735b2\Nette\DI\Resolver::autowireArguments() at phar:///home/wodby/.composer/vendor/phpstan/phpstan/phpstan.phar/vendor/nette/di/src/DI/Resolver.php:174
 _PHPStan_3334735b2\Nette\DI\Resolver->completeStatement() at phar:///home/wodby/.composer/vendor/phpstan/phpstan/phpstan.phar/vendor/nette/di/src/DI/Definitions/ServiceDefinition.php:135
 _PHPStan_3334735b2\Nette\DI\Definitions\ServiceDefinition->complete() at phar:///home/wodby/.composer/vendor/phpstan/phpstan/phpstan.phar/vendor/nette/di/src/DI/Resolver.php:127
 _PHPStan_3334735b2\Nette\DI\Resolver->completeDefinition() at phar:///home/wodby/.composer/vendor/phpstan/phpstan/phpstan.phar/vendor/nette/di/src/DI/ContainerBuilder.php:256
 _PHPStan_3334735b2\Nette\DI\ContainerBuilder->complete() at phar:///home/wodby/.composer/vendor/phpstan/phpstan/phpstan.phar/vendor/nette/di/src/DI/Compiler.php:203
 _PHPStan_3334735b2\Nette\DI\Compiler->processBeforeCompile() at phar:///home/wodby/.composer/vendor/phpstan/phpstan/phpstan.phar/vendor/nette/di/src/DI/Compiler.php:159
 _PHPStan_3334735b2\Nette\DI\Compiler->compile() at phar:///home/wodby/.composer/vendor/phpstan/phpstan/phpstan.phar/vendor/nette/di/src/DI/ContainerLoader.php:99
 _PHPStan_3334735b2\Nette\DI\ContainerLoader->generate() at phar:///home/wodby/.composer/vendor/phpstan/phpstan/phpstan.phar/vendor/nette/di/src/DI/ContainerLoader.php:65
 _PHPStan_3334735b2\Nette\DI\ContainerLoader->loadFile() at phar:///home/wodby/.composer/vendor/phpstan/phpstan/phpstan.phar/vendor/nette/di/src/DI/ContainerLoader.php:34
 _PHPStan_3334735b2\Nette\DI\ContainerLoader->load() at phar:///home/wodby/.composer/vendor/phpstan/phpstan/phpstan.phar/src/DependencyInjection/Configurator.php:56
 PHPStan\DependencyInjection\Configurator->loadContainer() at phar:///home/wodby/.composer/vendor/phpstan/phpstan/phpstan.phar/vendor/nette/bootstrap/src/Bootstrap/Configurator.php:177
 _PHPStan_3334735b2\Nette\Bootstrap\Configurator->createContainer() at phar:///home/wodby/.composer/vendor/phpstan/phpstan/phpstan.phar/src/DependencyInjection/Configurator.php:68
 PHPStan\DependencyInjection\Configurator->createContainer() at phar:///home/wodby/.composer/vendor/phpstan/phpstan/phpstan.phar/src/DependencyInjection/ContainerFactory.php:122
 PHPStan\DependencyInjection\ContainerFactory->create() at phar:///home/wodby/.composer/vendor/phpstan/phpstan/phpstan.phar/src/Command/CommandHelper.php:245
 PHPStan\Command\CommandHelper::begin() at phar:///home/wodby/.composer/vendor/phpstan/phpstan/phpstan.phar/src/Command/AnalyseCommand.php:114
 PHPStan\Command\AnalyseCommand->execute() at phar:///home/wodby/.composer/vendor/phpstan/phpstan/phpstan.phar/vendor/symfony/console/Command/Command.php:259
 _PHPStan_3334735b2\Symfony\Component\Console\Command\Command->run() at phar:///home/wodby/.composer/vendor/phpstan/phpstan/phpstan.phar/vendor/symfony/console/Application.php:870
 _PHPStan_3334735b2\Symfony\Component\Console\Application->doRunCommand() at phar:///home/wodby/.composer/vendor/phpstan/phpstan/phpstan.phar/vendor/symfony/console/Application.php:261
 _PHPStan_3334735b2\Symfony\Component\Console\Application->doRun() at phar:///home/wodby/.composer/vendor/phpstan/phpstan/phpstan.phar/vendor/symfony/console/Application.php:157
 _PHPStan_3334735b2\Symfony\Component\Console\Application->run() at phar:///home/wodby/.composer/vendor/phpstan/phpstan/phpstan.phar/bin/phpstan:124
 _PHPStan_3334735b2\{closure}() at phar:///home/wodby/.composer/vendor/phpstan/phpstan/phpstan.phar/bin/phpstan:125
 require() at /home/wodby/.composer/vendor/phpstan/phpstan/phpstan.phar:6

In Autowiring.php line 53:

  [_PHPStan_3334735b2\Nette\DI\ServiceCreationException]                       
  Multiple services of type mglaman\PHPStanDrupal\Drupal\ServiceMap found: 03  
  44, 0366                                                                     

Exception trace:
  at phar:///home/wodby/.composer/vendor/phpstan/phpstan/phpstan.phar/vendor/nette/di/src/DI/Autowiring.php:53
 _PHPStan_3334735b2\Nette\DI\Autowiring->getByType() at phar:///home/wodby/.composer/vendor/phpstan/phpstan/phpstan.phar/vendor/nette/di/src/DI/ContainerBuilder.php:174
 _PHPStan_3334735b2\Nette\DI\ContainerBuilder->getByType() at phar:///home/wodby/.composer/vendor/phpstan/phpstan/phpstan.phar/vendor/nette/di/src/DI/Resolver.php:316
 _PHPStan_3334735b2\Nette\DI\Resolver->getByType() at phar:///home/wodby/.composer/vendor/phpstan/phpstan/phpstan.phar/vendor/nette/di/src/DI/Resolver.php:141
 _PHPStan_3334735b2\Nette\DI\Resolver->_PHPStan_3334735b2\Nette\DI\{closure}() at phar:///home/wodby/.composer/vendor/phpstan/phpstan/phpstan.phar/vendor/nette/di/src/DI/Resolver.php:466
 _PHPStan_3334735b2\Nette\DI\Resolver::autowireArgument() at phar:///home/wodby/.composer/vendor/phpstan/phpstan/phpstan.phar/vendor/nette/di/src/DI/Resolver.php:422
 _PHPStan_3334735b2\Nette\DI\Resolver::autowireArguments() at phar:///home/wodby/.composer/vendor/phpstan/phpstan/phpstan.phar/vendor/nette/di/src/DI/Resolver.php:174
 _PHPStan_3334735b2\Nette\DI\Resolver->completeStatement() at phar:///home/wodby/.composer/vendor/phpstan/phpstan/phpstan.phar/vendor/nette/di/src/DI/Definitions/ServiceDefinition.php:135
 _PHPStan_3334735b2\Nette\DI\Definitions\ServiceDefinition->complete() at phar:///home/wodby/.composer/vendor/phpstan/phpstan/phpstan.phar/vendor/nette/di/src/DI/Resolver.php:127
 _PHPStan_3334735b2\Nette\DI\Resolver->completeDefinition() at phar:///home/wodby/.composer/vendor/phpstan/phpstan/phpstan.phar/vendor/nette/di/src/DI/ContainerBuilder.php:256
 _PHPStan_3334735b2\Nette\DI\ContainerBuilder->complete() at phar:///home/wodby/.composer/vendor/phpstan/phpstan/phpstan.phar/vendor/nette/di/src/DI/Compiler.php:203
 _PHPStan_3334735b2\Nette\DI\Compiler->processBeforeCompile() at phar:///home/wodby/.composer/vendor/phpstan/phpstan/phpstan.phar/vendor/nette/di/src/DI/Compiler.php:159
 _PHPStan_3334735b2\Nette\DI\Compiler->compile() at phar:///home/wodby/.composer/vendor/phpstan/phpstan/phpstan.phar/vendor/nette/di/src/DI/ContainerLoader.php:99
 _PHPStan_3334735b2\Nette\DI\ContainerLoader->generate() at phar:///home/wodby/.composer/vendor/phpstan/phpstan/phpstan.phar/vendor/nette/di/src/DI/ContainerLoader.php:65
 _PHPStan_3334735b2\Nette\DI\ContainerLoader->loadFile() at phar:///home/wodby/.composer/vendor/phpstan/phpstan/phpstan.phar/vendor/nette/di/src/DI/ContainerLoader.php:34
 _PHPStan_3334735b2\Nette\DI\ContainerLoader->load() at phar:///home/wodby/.composer/vendor/phpstan/phpstan/phpstan.phar/src/DependencyInjection/Configurator.php:56
 PHPStan\DependencyInjection\Configurator->loadContainer() at phar:///home/wodby/.composer/vendor/phpstan/phpstan/phpstan.phar/vendor/nette/bootstrap/src/Bootstrap/Configurator.php:177
 _PHPStan_3334735b2\Nette\Bootstrap\Configurator->createContainer() at phar:///home/wodby/.composer/vendor/phpstan/phpstan/phpstan.phar/src/DependencyInjection/Configurator.php:68
 PHPStan\DependencyInjection\Configurator->createContainer() at phar:///home/wodby/.composer/vendor/phpstan/phpstan/phpstan.phar/src/DependencyInjection/ContainerFactory.php:122
 PHPStan\DependencyInjection\ContainerFactory->create() at phar:///home/wodby/.composer/vendor/phpstan/phpstan/phpstan.phar/src/Command/CommandHelper.php:245
 PHPStan\Command\CommandHelper::begin() at phar:///home/wodby/.composer/vendor/phpstan/phpstan/phpstan.phar/src/Command/AnalyseCommand.php:114
 PHPStan\Command\AnalyseCommand->execute() at phar:///home/wodby/.composer/vendor/phpstan/phpstan/phpstan.phar/vendor/symfony/console/Command/Command.php:259
 _PHPStan_3334735b2\Symfony\Component\Console\Command\Command->run() at phar:///home/wodby/.composer/vendor/phpstan/phpstan/phpstan.phar/vendor/symfony/console/Application.php:870
 _PHPStan_3334735b2\Symfony\Component\Console\Application->doRunCommand() at phar:///home/wodby/.composer/vendor/phpstan/phpstan/phpstan.phar/vendor/symfony/console/Application.php:261
 _PHPStan_3334735b2\Symfony\Component\Console\Application->doRun() at phar:///home/wodby/.composer/vendor/phpstan/phpstan/phpstan.phar/vendor/symfony/console/Application.php:157
 _PHPStan_3334735b2\Symfony\Component\Console\Application->run() at phar:///home/wodby/.composer/vendor/phpstan/phpstan/phpstan.phar/bin/phpstan:124
 _PHPStan_3334735b2\{closure}() at phar:///home/wodby/.composer/vendor/phpstan/phpstan/phpstan.phar/bin/phpstan:125
 require() at /home/wodby/.composer/vendor/phpstan/phpstan/phpstan.phar:6
Dropa commented 1 year ago

Update:

Looks like the error is relatively small. If running the command in project root (at least in drupal-project based) it's the only case this will fail.

~/projects/drupal/misc $ ~/.config/composer/vendor/bin/drupal-check vanilla/web/core/modules/history

works

~/projects/drupal/misc/vanilla $ ~/.config/composer/vendor/bin/drupal-check web/core/modules/history

doesn't work

~/projects/drupal/misc/vanilla/web $ ~/.config/composer/vendor/bin/drupal-check core/modules/history

works