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

Class incompatiblity between symfony/proxy-manager-bridge and laminas/laminas-code #41742

Closed
gaetan-petit opened this issue Jun 18, 2021 · 14 comments

Comments

@gaetan-petit
Copy link

Symfony version(s) affected: 3.4.49

Description
Updating dependencies through composer cause incompability with laminas/laminas-code

How to reproduce
Running composer update with package requiring ocramius/proxy-manager like symfony/proxy-manager-bridge

Possible Solution
As discussed with @Ocramius in laminas/laminas-code#89

Symfony\Bridge\ProxyManager\LazyProxy\PhpDumper\LazyLoadingValueHolderGenerator
seems to use zendframework/zend-code, but it doesn't declare a
dependency to it, hence why the class didn't get installed, and a
crash occurs.

The correct fix would be to declare a dependency there, and perhaps
plan a migration to laminas/laminas-code too

Additional context

composer update 
Loading composer repositories with package information
Restricting packages listed in "symfony/symfony" to "3.4.*"
Updating dependencies
Lock file operations: 0 installs, 5 updates, 2 removals
  - Removing laminas/laminas-eventmanager (3.3.1)
  - Removing laminas/laminas-zendframework-bridge (1.2.0)
  - Upgrading laminas/laminas-code (4.3.0 => 4.4.0)
Writing lock file
Installing dependencies from lock file (including require-dev)
Package operations: 0 installs, 5 updates, 2 removals
  - Downloading laminas/laminas-code (4.4.0)
  - Downloading phpstan/phpstan (0.12.90)
  - Removing laminas/laminas-zendframework-bridge (1.2.0)
  - Removing laminas/laminas-eventmanager (3.3.1)
  - Upgrading laminas/laminas-code (4.3.0 => 4.4.0): Extracting archive
Generating autoload files
composer/package-versions-deprecated: Generating version class...
composer/package-versions-deprecated: ...done generating version class

Symfony operations: 2 recipes (5471d04139cfeb8c88ad90ba4a997ba1)
  - Unconfiguring laminas/laminas-zendframework-bridge (>=1.2.0): From auto-generated recipe
  - Unconfiguring laminas/laminas-eventmanager (>=3.3.1): From auto-generated recipe
Executing script cache:clear --no-warmup [KO]
 [KO]
Script cache:clear --no-warmup returned with error code 255
!!  PHP Fatal error:  Could not check compatibility between Symfony\Bridge\ProxyManager\LazyProxy\PhpDumper\LazyLoadingValueHolderGenerator::generate(ReflectionClass $originalClass, Zend\Code\Generator\ClassGenerator $classGenerator) and ProxyManager\ProxyGenerator\LazyLoadingValueHolderGenerator::generate(ReflectionClass $originalClass, Laminas\Code\Generator\ClassGenerator $classGenerator), because class Zend\Code\Generator\ClassGenerator is not available in /var/www/marketplace/vendor/symfony/proxy-manager-bridge/LazyProxy/PhpDumper/LazyLoadingValueHolderGenerator.php on line 25

Requiring laminas/laminas-zendframework-bridge seems to fix the problem.

@Ocramius
Copy link
Contributor

Ocramius commented Jun 18, 2021 via email

@gaetan-petit gaetan-petit changed the title Class imcompatiblity between symfony/proxy-manager-bridge and laminas/laminas-code Class incompatiblity between symfony/proxy-manager-bridge and laminas/laminas-code Jun 18, 2021
@nicolas-grekas
Copy link
Member

nicolas-grekas commented Jun 18, 2021

Thanks for the report.
3.4 is not maintained anymore so I'm going to close.
This issue has been fixed in 4.4 by using friendsofphp/proxy-manager-lts instead of ocramius/proxy-manager.
You should be able to do so in a 3.4 app also.

@Ocramius

This comment has been minimized.

@gaetan-petit
Copy link
Author

This issue has been fixed in 4.4 by using friendsofphp/proxy-manager-lts instead of ocramius/proxy-manager.
You should be able to do so in a 3.4 app also.

No you can't as several dependencies are directly requiring on ocramius/proxy-manager.
I know that 3.4 is approaching EOL, but if it's has simple as updating dependencies could you consider it?

@nicolas-grekas
Copy link
Member

nicolas-grekas commented Jun 18, 2021

you can't as several dependencies are directly requiring on ocramius/proxy-manager.

actually friendsofphp/proxy-manager-lts "replaces" ocramius/proxy-manager from a composer pov, so it really works even if deps directly require it.

I know that 3.4 is approaching EOL, but if it's has simple as updating dependencies could you consider it?

We have to draw a line and stick to it, that's been annouced years ahead...

@gaetan-petit
Copy link
Author

gaetan-petit commented Jun 18, 2021

actually friendsofphp/proxy-manager-lts "replaces" ocramius/proxy-manager from a composer pov, so it really works even if deps directly require it.

Can't do that either it requires symfony/filesystem ^4.4.17|^5.0|^6.0 and it's incompatible with a 3.4 application.

We have to draw a line and stick to it, that's been annouced years ahead...

I understand, we're actually just a step from switching to 4.4. It's just that it'll clearly break many 3.4 from updating dependencies (including possible security update).

@wouterj
Copy link
Member

wouterj commented Jun 18, 2021

That's the risk of using a version that reached end of life 8 months ago. There is not much we can do I'm afraid (apart from fixing the bug in currently maintained versions if it's there).

@nicolas-grekas
Copy link
Member

@gaetan-petit indeed, good luck with the upgrade! I realized there is one more thing you can do, which is to stick to laminas/laminas-code < 4.4, which is the version that introduced the change you're seeing.

@gaetan-petit
Copy link
Author

That's the risk of using a version that reached end of life 8 months ago. There is not much we can do I'm afraid (apart from fixing the bug in currently maintained versions if it's there).

Thanks @wouterj (I guess) but in my previous post I said that we're actually finishing the migration.

@beberlei
Copy link
Contributor

@gaetan-petit You can fix that yourself by adding class_alias calls for laminas code to zend code.

I used this temporary fix:

require_once __DIR__ . '/vendor/laminas/laminas-code/src/Generator/GeneratorInterface.php';
require_once __DIR__ . '/vendor/laminas/laminas-code/src/Generator/AbstractGenerator.php';
require_once __DIR__ . '/vendor/laminas/laminas-code/src/Generator/TraitUsageInterface.php';
require_once __DIR__ . '/vendor/laminas/laminas-code/src/Generator/ClassGenerator.php';

    class_alias("Laminas\Code\Generator\GeneratorInterface",
        "Zend\Code\Generator\GeneratorInterface");
    class_alias("Laminas\Code\Generator\AbstractGenerator",
        "Zend\Code\Generator\AbstractGenerator",);
    class_alias("Laminas\Code\Generator\TraitUsageInterface",
        "Zend\Code\Generator\TraitUsageInterface",);
    class_alias("Laminas\Code\Generator\ClassGenerator",
        "Zend\Code\Generator\ClassGenerator",);

@Thykof
Copy link

Thykof commented Aug 9, 2021

Hello,

I am working with symfony 5.0 and had the this error: Could not check compatibility between Symfony\Bridge\ProxyManager\LazyProxy\PhpDumper\LazyLoadingValueHolderGenerator::generate(ReflectionClass $originalClass, Zend\Code\Generator\ClassGenerator $classGenerator): void and ProxyManager\ProxyGenerator\LazyLoadingValueHolderGenerator::generate(ReflectionClass $originalClass, Laminas\Code\Generator\ClassGenerator $classGenerator), because class Zend\Code\Generator\ClassGenerator is not available in /home/nathan/dev/plateforme/facturation/vendor/symfony/proxy-manager-bridge/LazyProxy/PhpDumper/LazyLoadingValueHolderGenerator.php on line 33

Running this fixed the problem: composer require laminas/laminas-zendframework-bridge, thanks to laminas/laminas-code#37 (comment) but this is not the ideal solution.

Upgrading to symfony 5.3 fixed the problem.

@nicogit2001
Copy link

Worked for me. Thanks.

@rohlacanna
Copy link

Symfony version(s) affected: 3.4.49

Description Updating dependencies through composer cause incompability with laminas/laminas-code

How to reproduce Running composer update with package requiring ocramius/proxy-manager like symfony/proxy-manager-bridge

Possible Solution As discussed with @Ocramius in laminas/laminas-code#89

Symfony\Bridge\ProxyManager\LazyProxy\PhpDumper\LazyLoadingValueHolderGenerator
seems to use zendframework/zend-code, but it doesn't declare a
dependency to it, hence why the class didn't get installed, and a
crash occurs.
The correct fix would be to declare a dependency there, and perhaps
plan a migration to laminas/laminas-code too

Additional context

composer update 
Loading composer repositories with package information
Restricting packages listed in "symfony/symfony" to "3.4.*"
Updating dependencies
Lock file operations: 0 installs, 5 updates, 2 removals
  - Removing laminas/laminas-eventmanager (3.3.1)
  - Removing laminas/laminas-zendframework-bridge (1.2.0)
  - Upgrading laminas/laminas-code (4.3.0 => 4.4.0)
Writing lock file
Installing dependencies from lock file (including require-dev)
Package operations: 0 installs, 5 updates, 2 removals
  - Downloading laminas/laminas-code (4.4.0)
  - Downloading phpstan/phpstan (0.12.90)
  - Removing laminas/laminas-zendframework-bridge (1.2.0)
  - Removing laminas/laminas-eventmanager (3.3.1)
  - Upgrading laminas/laminas-code (4.3.0 => 4.4.0): Extracting archive
Generating autoload files
composer/package-versions-deprecated: Generating version class...
composer/package-versions-deprecated: ...done generating version class

Symfony operations: 2 recipes (5471d04139cfeb8c88ad90ba4a997ba1)
  - Unconfiguring laminas/laminas-zendframework-bridge (>=1.2.0): From auto-generated recipe
  - Unconfiguring laminas/laminas-eventmanager (>=3.3.1): From auto-generated recipe
Executing script cache:clear --no-warmup [KO]
 [KO]
Script cache:clear --no-warmup returned with error code 255
!!  PHP Fatal error:  Could not check compatibility between Symfony\Bridge\ProxyManager\LazyProxy\PhpDumper\LazyLoadingValueHolderGenerator::generate(ReflectionClass $originalClass, Zend\Code\Generator\ClassGenerator $classGenerator) and ProxyManager\ProxyGenerator\LazyLoadingValueHolderGenerator::generate(ReflectionClass $originalClass, Laminas\Code\Generator\ClassGenerator $classGenerator), because class Zend\Code\Generator\ClassGenerator is not available in /var/www/marketplace/vendor/symfony/proxy-manager-bridge/LazyProxy/PhpDumper/LazyLoadingValueHolderGenerator.php on line 25

Requiring laminas/laminas-zendframework-bridge seems to fix the problem.

When I try to install laminas / laminas-zend framework-bridge, it gives me an error saying Class "1\ApiContentController" does not exist.

How do I solve this?

theus77 added a commit to ems-project/elasticms-admin that referenced this issue Dec 24, 2021
@Saoussene-Toubal
Copy link

Saoussene-Toubal commented Jan 13, 2022

hiii symfony 3.4 worked for me
by execute : composer require laminas/laminas-zendframework-bridge

mbhoir added a commit to mbhoir/signalfx-php-tracing that referenced this issue Mar 9, 2022
snehalrayamwala pushed a commit to snehalrayamwala/signalfx-php-tracing that referenced this issue Mar 11, 2022
snehalrayamwala pushed a commit to snehalrayamwala/signalfx-php-tracing that referenced this issue Mar 17, 2022
agoallikmaa pushed a commit to agoallikmaa/signalfx-php-tracing that referenced this issue Jul 31, 2022
alexarn added a commit to PlanningBiblio/PlanningBiblio that referenced this issue Nov 22, 2022
laminas/laminas-code.
See the related symfony issue: symfony/symfony#41742

And add ics-parser 3.x to composer
pomowunk added a commit to pomowunk/Runalyze that referenced this issue May 23, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

10 participants