php-enum icon indicating copy to clipboard operation
php-enum copied to clipboard

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

Open fredericgboutin-yapla opened this issue 4 months ago • 0 comments

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 https://github.com/composer/composer/issues/6221#issuecomment-2402661924

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 avatar Oct 09 '24 15:10 fredericgboutin-yapla