Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Suppress “Ambiguous class resolution” warning

Is there a way to disable the “Ambiguous class resolution” warning when running composer install?

I use a package which has classes with the same name (and namespace) in different folders.

I know of this bug, but it's not that because the classes are actually twice in the vendor. I just can't do anything about it.

I'm also aware of the --no-autoloader flag which of course doesn't throw the warning, but just because it skips the autoloader generation.

like image 275
Christian Kolb Avatar asked Jan 08 '23 16:01

Christian Kolb


1 Answers

Instead of removing files from vendor directory (which should be avoided) it is better to add files/direactories with ambiguous classes to exclude-from-classmap section in your composer.json:

"autoload": {
    ...
    "exclude-from-classmap": [
        "vendor/somevendor/somepackage/directory/with/ambiguous/classes/",
        "vendor/somevendor/somepackage/src/AmbiguousClass.php"
    ]
},

Then Composer will ignore these files during classmap generation.

like image 75
rob006 Avatar answered Jan 17 '23 16:01

rob006