Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Undefined constant PhpParser\Node\Expr\List_::KIND_LIST #1023

Open
gabrielrbarbosa opened this issue Sep 12, 2024 · 5 comments
Open

Undefined constant PhpParser\Node\Expr\List_::KIND_LIST #1023

gabrielrbarbosa opened this issue Sep 12, 2024 · 5 comments

Comments

@gabrielrbarbosa
Copy link

pestphp/pest#1244

FAILED  Tests\Unit\ArchTest > expect 'App\Http' → toOnlyBeUsedIn 'App\Http'                                                                                  Error
  Undefined constant PhpParser\Node\Expr\List_::KIND_LIST

  at vendor/nikic/php-parser/lib/PhpParser/Parser/Php8.php:2642
    2638▕             588 => static function ($self, $stackPos) {
    2639▕                  $self->semValue = new Expr\Error($self->getAttributes($self->tokenStartStack[$stackPos-(1-1)], $self->tokenEndStack[$stackPos])); $self->errorState = 2;
    2640▕             },
    2641▕             589 => static function ($self, $stackPos) {
  ➜ 2642▕                  $self->semValue = new Expr\List_($self->semStack[$stackPos-(4-3)], $self->getAttributes($self->tokenStartStack[$stackPos-(4-1)], $self->tokenEndStack[$stackPos])); $self->semValue->setAttribute('kind', Expr\List_::KIND_LIST);
    2643▕             $self->postprocessList($self->semValue);
    2644▕             },
    2645▕             590 => static function ($self, $stackPos) {
    2646▕                  $self->semValue = $self->semStack[$stackPos-(1-1)]; $end = count($self->semValue)-1; if ($self->semValue[$end]->value instanceof Expr\Error) array_pop($self->semValue);
@xabbuh
Copy link

xabbuh commented Sep 12, 2024

Which version of this library do you have installed?

@gabrielrbarbosa
Copy link
Author

@xabbuh nikic/php-parser 5.1.0

@xabbuh
Copy link

xabbuh commented Sep 12, 2024

The constant is defined in that version:

public const KIND_LIST = 1; // list() syntax

Maybe you have different versions installed and autoloading mixes files from different versions.

@gabrielrbarbosa
Copy link
Author

Not sure about that because it happened both in my local env and bitbucket-pipelines using 5.1.0

@staabm
Copy link
Contributor

staabm commented Sep 12, 2024

This might happen when e.g. PHPStan or Rector or similar tools include a nikc/php-parser version in .phar files and you install a incompatible version in top

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants