Supress "Ambiguous class resolution"-warning

1,015 views
Skip to first unread message

Suralc

unread,
Apr 27, 2014, 5:53:58 AM4/27/14
to compose...@googlegroups.com

Hello, 
 
Is there a way to suppress the "Ambiguous class resolution" warning generated by "dump-autoload --optimize" without ignoring all other warnings? 
Such a warning is atm breaking our deploys on openshift. We could (and we do it right now) redirect all messages away from stderr to a log file to let the deploy succeed (or use --quiet), however we want other warnings to stay in place for obvious reasons. The warning is triggered by a dependency of a dependency, so fixing it at the real source is not an ideal approach, either. 
 
A friend opened  a question on SO. However, I think that this list is more appropriate.

Link to so:
http://stackoverflow.com/questions/23316761/suppress-ambiguous-class-resolution-warning-on-composer-dump-autoload-o



Jordi Boggiano

unread,
Apr 27, 2014, 10:03:38 AM4/27/14
to compose...@googlegroups.com
I am not sure what the problem is because I actually can not reproduce
it with the latest version of composer.

Can you make sure you have the issue still after a composer self-update?

Cheers
> --
> You received this message because you are subscribed to the Google
> Groups "composer-users" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to composer-user...@googlegroups.com
> <mailto:composer-user...@googlegroups.com>.
> For more options, visit https://groups.google.com/d/optout.


--
Jordi Boggiano
@seldaek - http://nelm.io/jordi

Suralc

unread,
Apr 29, 2014, 6:12:56 AM4/29/14
to compose...@googlegroups.com
Composer version 29c39cc2662547b1128149d1a4c7ddf93c69bb9d 2014-04-28 15:57:52


I can't reproduce this outside of the project. However it reproduces locally fine using this gist (composer install --prefer-dist && composer dump-autoload -o):
https://gist.github.com/suralc/71bba09c6895776d51a1 (modified composer.json to remove some email-addresses and dev-dependencies, so it may complain that it does not match with composer.lock. The issue is however present with the same effects as with the "real" composer.json)

But I must correct myself, my issue was not really clear from the first post. 

The warning is breaking my deploy. The platform recognizes the warning as failure and aborts the deploy, wich is fine, as composer can't know which class is correct and may load the wrong one, leading to weird and hard-to-debug behaviour. However, the correct classes seem to be loaded, no tests are failing in this case.

I don't have access to the dependecy and don't require it myself, so I don't see a way to fix this without forking. It is a dependency of a dependency.

I could likely use the -q option, however I want to see other warnings and messages generated by other packages and want them to fail the deploy, atleast while the project is restricted to a small audience. So redirecting output is also not ideal.

My rephrased question:

Is it possible to :
  • disable warnings for a specific package
  • or to exclude a specific package from autoload optimization



Jordi Boggiano

unread,
Apr 29, 2014, 6:48:51 AM4/29/14
to compose...@googlegroups.com
On 29/04/2014 12:12, Suralc wrote:
> * make composer only include classes that are autoloadable in the
> optimized classmap:
> o The path that has the 2nd class definition is not autoloadable
> by default:
> https://github.com/ezyang/htmlpurifier/blob/344e0640b6610883a0aa6766cc6750d26d091c76/composer.json

There is no "autoloadable by not default". Either it's autoloadable or
it is not. That's why the warning makes no sense unless you have an
outdated composer or possibly an outdated htmlpurifier version which had
a broader autoload config (you can check that with `composer show -i
ezyang/htmlpurifier` - what does that output for the autoload config?).

> * disable warnings for a specific package

No

> * or to exclude a specific package from autoload optimization

No

Suralc

unread,
Apr 29, 2014, 7:04:15 AM4/29/14
to compose...@googlegroups.com
As I already posted:
composer selfupdate && composer --version
  • You are already using composer version 29c39cc2662547b1128149d1a4c7ddf93c69bb9d.
  • Composer version 29c39cc2662547b1128149d1a4c7ddf93c69bb9d 2014-04-28 15:57:52
    composer show -i and composer dump-autoload directly after that:

    composer show -i ezyang/htmlpurifier

    name     : ezyang/htmlpurifier
    descrip. : Standards compliant HTML filter written in PHP
    keywords : html
    versions : * v4.6.0
    type     : library
    license  : LGPL
    source   : [git] https://github.com/ezyang/htmlpurifier.git 6f389f0f25b90d0b4953
    08efcfa073981177f0fd
    dist     : [zip] https://api.github.com/repos/ezyang/htmlpurifier/zipball/6f389f
    0f25b90d0b495308efcfa073981177f0fd 6f389f0f25b90d0b495308efcfa073981177f0fd
    names    : ezyang/htmlpurifier

    autoload
    psr-0
    HTMLPurifier => library/
    files

    requires
    php >=5.2
    composer dump-autoload -o

    Generating optimized autoload files
    Warning: Ambiguous class resolution, "HTML5" was found in both ".\vendor\ezyang\htmlpurifier\library\HTMLPurifier\Lexer\PH5P.php" and ".\vendor\ezyang\htmlpurifier\maintenance\PH5P.php", the first will be used.

    Warning: Ambiguous class resolution, "HTML5TreeConstructer" was found in both ".\vendor\ezyang\htmlpurifier\library\HTMLPurifier\Lexer\PH5P.
    php" and ".\vendor\ezyang\htmlpurifier\maintenance\PH5P.php"
    , the first will be used.


    Parth shortened, nothing else changed. 4.6 is the latest tagged version. Git hash matches the tag.

    Jordi Boggiano

    unread,
    Apr 29, 2014, 8:37:03 AM4/29/14
    to compose...@googlegroups.com
    Ah now I got it.. the problem is you mapped the root directory of your
    project in your autoload config:

    "autoload": {
    "psr-4": {
    "\\app\\": "."
    }
    },

    So it looks for all classes in the current dir, and while we did exclude
    classes not within the app\ namespace, this was done after printing the
    warnings out. I just fixed that so you can try again, after a `composer
    self-update` it should work fine :)

    Cheers

    On 29/04/2014 13:04, Suralc wrote:
    > As I already posted:
    > composer selfupdate && composer --version
    >
    > * You are already using composer version
    > 29c39cc2662547b1128149d1a4c7ddf93c69bb9d.
    > * Composer version 29c39cc2662547b1128149d1a4c7ddf93c69bb9d 2014-04-28
    > 15:57:52
    >
    > composer show -i and composer dump-autoload directly after that:
    >
    > /composer show -i ///ezyang/htmlpurifier
    >
    > /name : ezyang/htmlpurifier
    > , the first will be used./
    >
    > Parth shortened, nothing else changed. 4.6 is the latest tagged version.
    > Git hash matches the tag.
    >
    > Am Dienstag, 29. April 2014 12:48:51 UTC+2 schrieb Jordi Boggiano:
    >
    > On 29/04/2014 12:12, Suralc wrote:
    > > * make composer only include classes that are autoloadable in the
    > > optimized classmap:
    > > o The path that has the 2nd class definition is not
    > autoloadable
    > > by default:
    > >
    > https://github.com/ezyang/htmlpurifier/blob/344e0640b6610883a0aa6766cc6750d26d091c76/composer.json
    > <https://github.com/ezyang/htmlpurifier/blob/344e0640b6610883a0aa6766cc6750d26d091c76/composer.json>
    >
    >
    > There is no "autoloadable by not default". Either it's autoloadable or
    > it is not. That's why the warning makes no sense unless you have an
    > outdated composer or possibly an outdated htmlpurifier version which
    > had
    > a broader autoload config (you can check that with `composer show -i
    > ezyang/htmlpurifier` - what does that output for the autoload config?).
    >
    > > * disable warnings for a specific package
    >
    > No
    >
    > > * or to exclude a specific package from autoload optimization
    >
    > No
    >
    >
    >
    > --
    > Jordi Boggiano
    > @seldaek - http://nelm.io/jordi
    >
    > --
    > You received this message because you are subscribed to the Google
    > Groups "composer-users" group.
    > To unsubscribe from this group and stop receiving emails from it, send
    > an email to composer-user...@googlegroups.com
    > <mailto:composer-user...@googlegroups.com>.
    > For more options, visit https://groups.google.com/d/optout.


    Suralc

    unread,
    Apr 29, 2014, 9:09:21 AM4/29/14
    to compose...@googlegroups.com
    Thank you for your effords ;)

    Tried it locally and it seems to be fixed. Will try it remote later this day.

    Again, thank you.
    Reply all
    Reply to author
    Forward
    0 new messages