Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

This package should not "replace" zend/code #37

Closed
BenMorel opened this issue Jan 24, 2020 · 11 comments
Closed

This package should not "replace" zend/code #37

BenMorel opened this issue Jan 24, 2020 · 11 comments

Comments

@BenMorel
Copy link

Bug Report

Q A
Version(s) 3.4.1

Summary

This package is marked as replacing zendframework/zend-code:

"replace": {
"zendframework/zend-code": "self.version"
}

There seems to be a misunderstanding in what replace actually does: the package must be 100% compatible with the replaced one, which is obviously not the case here.

As it stands, this breaks composer installations and throws class not found errors.

Sure, you can install the laminas/laminas-zendframework-bridge, but composer doesn't do that automatically.

Current behavior

Class 'Zend\Code\Generator\ClassGenerator' not found

How to reproduce

Install ocramius/proxy-manager on PHP 7.3; try to use it.

@BenMorel
Copy link
Author

Sorry, I just realized that this package does require laminas/laminas-zendframework-bridge, so there is no bug here.

There is, however, an issue with composer autoloading I think:

  • by default, in --no-dev mode, the Class not found error occurs:
    $ composer install --no-dev
    $ bin/console doctrine:migrations:migrate prev -n
    

    Migration 035 failed during Pre-Checks. Error Class 'Zend\Code\Generator\ClassGenerator' not found

  • if I manually require laminas/laminas-zendframework-bridge, it now works:
    $ composer require laminas/laminas-zendframework-bridge
    $ composer install --no-dev
    $ bin/console doctrine:migrations:migrate prev -n
    

    Migrating down to 034 from 035
    (...)

Even though diffing composer.lock shows no changes, apart from the content-hash, manually requiring the bridge fixes the issue.

Is this a bug with composer, should I file a bug there?

@BenMorel
Copy link
Author

Looks like I somehow ended up with a broken composer config. Here's how I fixed it:

rm -rf vendor
rm -f composer.lock
rm -f symfony.lock
composer update
composer install --no-dev

Tell me why, but laminas/laminas-code was now replaced with zendframework/zend-code, and the problem is gone for me.

I believe there's a bug somehow with composer, but I wasn't able to make a reproducible test case after more than one hour, so I'm giving up now.

Maybe the steps above will help someone with the same issue I encountered.

@magnetik
Copy link

magnetik commented Feb 6, 2020

I had the same problem. I suspect symfony flex to have messed with the dependencies.

IMO the bug should be open as I think you are right about the fact that this package is NOT a "replace"(ment) of zend-code.

@BenMorel
Copy link
Author

BenMorel commented Feb 6, 2020

@magnetik IDK, because it requires the bridge, it effectively replaces zend-code, with no modification required on code using the library.

@Xerkus
Copy link
Member

Xerkus commented Feb 6, 2020

@magnetik are you using latest composer version?

@magnetik
Copy link

magnetik commented Feb 6, 2020

I'm running 1.9.2

@magnetik
Copy link

magnetik commented Feb 6, 2020

Hum but maybe that's someone on my team that was using 1.8.6 that did the composer update. Could this be it?

@crmpicco
Copy link

Looks like I somehow ended up with a broken composer config. Here's how I fixed it:

rm -rf vendor
rm -f composer.lock
rm -f symfony.lock
composer update
composer install --no-dev

Tell me why, but laminas/laminas-code was now replaced with zendframework/zend-code, and the problem is gone for me.

I believe there's a bug somehow with composer, but I wasn't able to make a reproducible test case after more than one hour, so I'm giving up now.

Maybe the steps above will help someone with the same issue I encountered.

Thanks a bunch for this comment. This is exactly what I had to do.

@Xerkus
Copy link
Member

Xerkus commented Feb 18, 2020

There is some kind of issue here that looks more of a support kind rather than a bug.
Please take it to our discourse forums so we can figure it out and help you.

@BenMorel
Copy link
Author

@Xerkus Indeed, I don't think there's any issue with laminas-code.
This is more likely a Composer bug. Closing.

@remorhaz
Copy link

Probably this one I've just discovered. If yes then temporary workaround is just not to use --no-dev key.

composer/composer#8622

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants