Closed nicrodgers closed 4 years ago
Can you paste your composer file and steps to reproduce the error?
It's on a project with a pretty huge composer file. I'll see if I can create an example with a minimal amount of projects required.
Here we go - was easier than I thought :)
composer.json:
{
"require": {
"mglaman/drupal-check": "^1.1",
"phpro/grumphp-shim": "^0.19.0"
}
}
steps to reproduce:
result: PHP warning is displayed Warning: Cannot declare interface Stringable, because the name is already in use in phar:///Volumes/www/sandbox/grumphp/vendor/phpstan/phpstan/phpstan.phar/vendor/symfony/polyfill-php80/Resources/stubs/Stringable.php on line 12
Maybe I need to a file a bug on the PHPStan project instead? Let me know what you think. Thanks.
It looks more like a PHPStan issue:
First it makes sure composer always loads the phpstan bootstrap file: https://github.com/phpstan/phpstan/blob/master/composer.json#L21
Next, it registers an autoloader that only works inside phars (which grumphp-shim is) https://github.com/phpstan/phpstan/blob/master/bootstrap.php This is most likely under the assumption that it only runs for phpstan?
The phpstan package also contain the php-80 stubs, so that is why you are seeing the Warning. It is indeed not blocking, but still a bit strange.
GrumPHP will always try to load the project specific autoloader to make sure local classes can be loaded as well.
Thanks for looking in to this and providing such comprehensive feedback so quickly! I'll raise an issue with the phpstan team.
Just posting the link to the phpstan issue for anyone who might land on this in the future: https://github.com/phpstan/phpstan/issues/3457
I get this error when trying to composer require phpro/grumphp-shim
PHP Warning: Cannot declare interface Stringable, because the name is already in use in phar:///app/vendor/phpstan/phpstan/phpstan.phar/vendor/symfony/polyfill-php80/Resources/stubs/Stringable.php on line 12 PHP Stack trace: PHP 1. {main}() /app/vendor/phpro/grumphp-shim/grumphp.phar:0
but it does install ok, and I don't see the error again when running grumphp. Everything seems to work ok.