Skip to content

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

Open
@fredericgboutin-yapla

Description

@fredericgboutin-yapla

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.

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