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

Double class declaration when generating Composer autoload files due to the PHP polyfills in version 1.10.52 #10387

Closed
oliverklee opened this issue Jan 5, 2024 · 5 comments

Comments

@oliverklee
Copy link
Sponsor

Bug report

https://github.com/oliverklee/ext-seminars/actions/runs/7421448150/job/20194829356?pr=2883

Using PHPStan 1.10.52 together with the symfony/polyfill-php80 package (in version 1.28.0) introduces a second declaration of the class Symfony\Polyfill\Php80\Php80, which breaks the generation of the autoload files during composer install:

Generating autoload files
PHP Fatal error:  Cannot declare class Symfony\Polyfill\Php80\Php80, because the name is already in use in phar:///home/runner/work/ext-seminars/ext-seminars/.Build/vendor/phpstan/phpstan/phpstan.phar/vendor/symfony/polyfill-php80/Php80.php on line 21

Code snippet that reproduces the problem

No response

Expected output

No error during autoload file generation

Did PHPStan help you today? Did it make you happy in any way?

No response

Copy link

mergeable bot commented Jan 5, 2024

This bug report is missing a link to reproduction at phpstan.org/try.

It will most likely be closed after manual review.

@localheinz
Copy link
Contributor

I can confirm a similar problem.

Running

composer show | grep phpstan

yields

phpstan/phpdoc-parser                    1.25.0    PHPDoc parser with support for nullable, intersection and generic types
phpstan/phpstan                          1.10.52   PHPStan - PHP Static Analysis Tool

and running

composer show | grep polyfill

yields

symfony/polyfill-ctype                   v1.28.0   Symfony polyfill for ctype functions
symfony/polyfill-intl-grapheme           v1.28.0   Symfony polyfill for intl's grapheme_* functions
symfony/polyfill-intl-normalizer         v1.28.0   Symfony polyfill for intl's Normalizer class and related functions
symfony/polyfill-mbstring                v1.28.0   Symfony polyfill for the Mbstring extension
symfony/polyfill-php73                   v1.28.0   Symfony polyfill backporting some PHP 7.3+ features to lower PHP versions
symfony/polyfill-php80                   v1.28.0   Symfony polyfill backporting some PHP 8.0+ features to lower PHP versions
symfony/polyfill-php81                   v1.28.0   Symfony polyfill backporting some PHP 8.1+ features to lower PHP versions

Attempting to run tests with phpunit/phpunit, using vendor/autoload.php as bootstrapper, results in

vendor/bin/phpunit --configuration=test/Unit/phpunit.xml
PHPUnit 9.6.15 by Sebastian Bergmann and contributors.

Runtime:       PHP 7.4.33
Configuration: test/Unit/phpunit.xml
Random Seed:   1704457481

PHP Fatal error:  Cannot declare class Symfony\Polyfill\Php81\Php81, because the name is already in use in phar:///Users/am/Sites/ergebnis/rector-rules/vendor/phpstan/phpstan/phpstan.phar/vendor/symfony/polyfill-php81/Php81.php on line 19

Fatal error: Cannot declare class Symfony\Polyfill\Php81\Php81, because the name is already in use in phar:///Users/am/Sites/ergebnis/rector-rules/vendor/phpstan/phpstan/phpstan.phar/vendor/symfony/polyfill-php81/Php81.php on line 19

For reference, see https://github.com/ergebnis/rector-rules/actions/runs/7421738763/job/20195703344.

@ondrejmirtes
Copy link
Member

Please verify that https://github.com/phpstan/phpstan/releases/tag/1.10.53 fixes this for you.

@oliverklee
Copy link
Sponsor Author

Yes, version 1.10.53 fixes this for me. Thanks for the quick fix and release, @ondrejmirtes! ❤️

Copy link

github-actions bot commented Feb 6, 2024

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 6, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants