Skip to content

Incompatibility with symfony/polyfill-php80 #3419

@enumag

Description

@enumag

Bug report

Using phpstan while having symfony/polyfill-php80 installed leads to this error:

<unknown location> Child process error (exit code 255): PHP Fatal error:  Cannot declare interface Stringable, because the name is already in use in .../vendor/symfony/polyfill-php80/Resources/stubs/Stringable.php on line 3
Fatal error: Cannot declare interface Stringable, because the name is already in use in .../vendor/symfony/polyfill-php80/Resources/stubs/Stringable.php on line 3

In Stringable.php line 3:
                                                                                          
  [Symfony\Component\ErrorHandler\Error\FatalError]                                       
  Compile Error: Cannot declare interface Stringable, because the name is already in use  
                                                                                          

Exception trace:
  at .../vendor/symfony/polyfill-php80/Resources/stubs/Stringable.php:3

I added some dumps to see what defined the interface:

"phar://.../vendor/phpstan/phpstan/phpstan/vendor/symfony/polyfill-php80/Resources/stubs/Stringable.php"

Code snippet that reproduces the problem

Not completely sure but it might be enough to just add both symfony/polyfill-php80 and phpstan/phpstan to your composer.json and then run phpstan. I can try to create a reproducing minimal repo if you need it.

Expected output

No error expected.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions