zendframework / zf1

This project reached its end-of-life on 2016-09-28. Contains conversion of ZF1 subversion repo to git, from version 15234 forward, and only containing master and release-1.12 branches and 1.12 tags.
https://framework.zend.com/blog/2016-06-28-zf1-eol.html
BSD 3-Clause "New" or "Revised" License
360 stars 790 forks source link

Composer optimized autoloader error #328

Closed chriskl closed 9 years ago

chriskl commented 10 years ago

Hi Guys,

With 1.12.5 I get the following warning when using 'composer dump-autoload --optimize':

[exec] Warning: Ambiguous class resolution, "Zend_Test_PHPUnit_Constraint_DomQuery" was found in both "/var/lib/jenkins/jobs/navigate-branch-dev/workspace/src/vendor/zendframework/zendframework1/library/Zend/Test/PHPUnit/Constraint/DomQuery37.php" and "/var/lib/jenkins/jobs/navigate-branch-dev/workspace/src/vendor/zendframework/zendframework1/library/Zend/Test/PHPUnit/Constraint/DomQuery34.php", the first will be used.
[exec] Warning: Ambiguous class resolution, "Zend_Test_PHPUnit_Constraint_Redirect" was found in both "/var/lib/jenkins/jobs/navigate-branch-dev/workspace/src/vendor/zendframework/zendframework1/library/Zend/Test/PHPUnit/Constraint/Redirect34.php" and "/var/lib/jenkins/jobs/navigate-branch-dev/workspace/src/vendor/zendframework/zendframework1/library/Zend/Test/PHPUnit/Constraint/Redirect37.php", the first will be used.
[exec] Warning: Ambiguous class resolution, "Zend_Test_PHPUnit_Constraint_ResponseHeader" was found in both "/var/lib/jenkins/jobs/navigate-branch-dev/workspace/src/vendor/zendframework/zendframework1/library/Zend/Test/PHPUnit/Constraint/ResponseHeader34.php" and "/var/lib/jenkins/jobs/navigate-branch-dev/workspace/src/vendor/zendframework/zendframework1/library/Zend/Test/PHPUnit/Constraint/ResponseHeader37.php", the first will be used.

(This is a Jenkins build output)

It appears to mean that you have the same class definition twice in the code somehow.

froschdesign commented 10 years ago

Zend/Test/PHPUnit/Constraint/DomQuery.php:

if (version_compare(PHPUnit_Runner_Version::id(), '3.5', '>=')) {
    include(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'DomQuery37.php');
} else {
    include(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'DomQuery34.php');
}

The same for Zend_Test_PHPUnit_Constraint_Redirect and Zend_Test_PHPUnit_Constraint_ResponseHeader.

weierophinney commented 10 years ago

@chriskl We do have these classes defined twice, but it's on purpose. The reason is that we want to use a single class name, but have the behavior change based on the PHPUnit version used, due to differences in behavior between 3.4 and 3.7. We currently do this via a conditional include, as we cannot use class aliasing due to ZF1 supporting 5.2. We also cannot put in rules in the composer.json due to the fact that we cannot know what version of PHPUnit you will actually use when running tests.

Interestingly, I cannot actually recreate the error you're seeing with the most recent version of Composer (I'm on "14f35e812cd41746c4a4a7a2dec2b2365c8cdc61 2014-04-14 12:11:15"); running dump-autoload with or without the --optimize switch from the ZF1 repo generates no errors for me.

mhujer commented 10 years ago

Also works for me with latest composer version. I think that this can be closed and eventually reopened if @chriskl can provide composer.json which can be used to reproduce the issue.

chriskl commented 10 years ago

Here you go...

On 20 June 2014 02:23, Martin Hujer notifications@github.com wrote:

Also works for me with latest composer version. I think that this can be closed and eventually reopened if @chriskl https://github.com/chriskl can provide composer.json which can be used to reproduce the issue.

— Reply to this email directly or view it on GitHub https://github.com/zendframework/zf1/issues/328#issuecomment-46597777.

mhujer commented 10 years ago

Can't see it?

froschdesign commented 9 years ago

Closed due inactivity.