Skip to content

Can't load mglaman/phpstan-drupal as the DI container is not available #7795

@mfrieling

Description

@mfrieling

Bug Report

Subject Details
rector/rector v0.15.17
palantirnet/drupal-rector v0.15.0
phpstan/phpstan v1.10.0
mglaman/phpstan-drupal v1.1.29

I had mglaman/phpstan-drupal already installed and working and now installed palantirnet/drupal-rector as well. When executing vendor/bin/rector I get the following error message:

 [ERROR] "PHPStan\ShouldNotHappenException" thrown in                                                                   
         "/var/www/html/vendor/mglaman/phpstan-drupal/drupal-autoloader.php" on line 7 while loading bootstrap file     
         /var/www/html/vendor/mglaman/phpstan-drupal/drupal-autoloader.php: The autoloader did not receive the          
         container.

By adding some printf() outputs I could break this down to Rector\NodeTypeResolver\DependencyInjection\PHPStanExtensionsConfigResolver::resolve() detecting the drupal-autoloader.php of mglaman/phpstan-drupal. But that fails if the variable $container isn't set correctly, which here is the case.

Minimal PHP Code Causing Issue

No custom PHP code is required to cause this issue, just install the packages in the versions mentioned above.

Expected Behaviour

When resolving the extensions, simply skip mglaman/phpstan-drupal.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions