Larastan: PHPStan Internal error

Created on 3 Sep 2020  路  10Comments  路  Source: nunomaduro/larastan

  • Larastan Version: 0.6.4
  • --level used: 5

Description

When I run PHPStan, I get the following exception (flag -vvv used):

In StubPhpDocProvider.php line 150:

  [PHPStan\ShouldNotHappenException]  
  Internal error.                     

This config-file is used:

includes:
    - ./vendor/nunomaduro/larastan/extension.neon

parameters:
    paths:
        - app

    # The level 8 is the highest level
    level: 5                

Recently got this on 2 different codebases.

Most helpful comment

We had the same issue with our projects. Is not only @DavyDeCoster

And we don't have any stub, laravel 7 by default. In fact, is a new project with days of life

All 10 comments

Hi,

Maybe you can try running it with --debug to get more information.

That error looks like there is some issue within the stubs. But Larastan's stubs are ok. No errors in CI or in any of my personal projects. Do you have some stubs of your own?

We had the same issue with our projects. Is not only @DavyDeCoster

And we don't have any stub, laravel 7 by default. In fact, is a new project with days of life

  PHPStan\ShouldNotHappenException 

  Internal error.

  at phar://vendor/phpstan/phpstan/phpstan/src/PhpDoc/StubPhpDocProvider.php:150
    146|     }
    147|     private function initializeKnownElements() : void
    148|     {
    149|         if ($this->initializing) {
  > 150|             throw new \PHPStan\ShouldNotHappenException();
    151|         }
    152|         if ($this->initialized) {
    153|             return;
    154|         }

I think this may be a problem with PHPStan itself.

I created new Laravel 7 project, installed Larastan. Scanned app directory. No errors. So I'm not sure what is the issue here.

Which Laravel version are you using? Also did --debug give you more information?

@canvural Laravel 7.27.0 is used in my current project. My previous comment was the output of the debug-flag.

Can you try to analyze just one file? If it doesn't happen, can you try to find a file in which this error happens?

@canvural Something strange is happening. I've updated my dependencies through composer and now it's working again. For me updating zircote/swagger-php from 3.0.5 to 3.1.0 fixed the problem.

Ah yes. I saw issues related to that in PHPStan repo. https://github.com/zircote/swagger-php/issues/834 and https://github.com/zircote/swagger-php/issues/841

If @Jonatanmdez can also confirm this is the issue, we can close this I think.

Closing this one as it seems it's fixed. Please open a new issue if it continues.

Was this page helpful?
0 / 5 - 0 ratings