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

Stringable class definition introduces class resolution ambiguity when using symfony/polyfill-php80 #176

Open
fredericgboutin-yapla opened this issue Oct 9, 2024 · 0 comments

Comments

@fredericgboutin-yapla
Copy link

fredericgboutin-yapla commented Oct 9, 2024

Context

I started using the new --strict-ambiguous switch in composer,

composer dump-autoload --optimize --classmap-authoritative --no-dev --strict-psr --strict-ambiguous

And in PHP 7.4, I'm getting a warning,

Warning: Ambiguous class resolution, "Stringable" was found in both "/var/www/html/vendor/myclabs/php-enum/stubs/Stringable.php" and "/var/www/html/vendor/symfony/polyfill-php80/Resources/stubs/Stringable.php", the first will be used.

See composer/composer#6221 (comment)

I'm not directly using this component, it is done through another one, but I suppose one can easily reproduce the issue by requiring both this component and symfony/polyfill-php80 in composer.

Workaround

I added a directive in my composer.json file,

    "exclude-from-classmap": [
      "vendor/myclabs/php-enum/stubs/Stringable.php"
    ],

And the warning is gone.

Solution

I'm not sure 😅PHP 7.4 is EOL so 🤷

You really share the very same definition https://github.com/myclabs/php-enum/blob/master/stubs/Stringable.php as the one from https://github.com/symfony/polyfill-php80/blob/1.x/Resources/stubs/Stringable.php - I suppose it would be more honest to explicitly depend on the later?

I don't know.

@fredericgboutin-yapla fredericgboutin-yapla changed the title Stringable class definition introduce class resolution ambiguity when using symfony/polyfill-php80 Stringable class definition introduces class resolution ambiguity when using symfony/polyfill-php80 Oct 9, 2024
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

1 participant