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

"Call to a member function resolveScope() on null" on Symfony classes #8268

Closed
malteschlueter opened this issue Oct 16, 2023 · 2 comments · Fixed by rectorphp/rector-src#5183
Labels

Comments

@malteschlueter
Copy link

malteschlueter commented Oct 16, 2023

Bug Report

Subject Details
Rector version v0.18.5

I'm trying to develop a plugin in PHP 8.2 and Symfony 6.3 and want to downgrade it to PHP 7.4 using rector. For the application code it works fine, but I'm having a problem with some vendor classes (only Symfony classes). The error message is Could not process "/project-dir/downgrade-build/vendor/symfony/dependency-injection/ServiceLocator.php" file, due to: "System error: "Call to a member function resolveScope() on null"

I can't find a issue related to calling the resolveScope function.

This error occurs in the following classes

  • symfony/dependency-injection/ServiceLocator.php
  • symfony/dependency-injection/Compiler/ResolveChildDefinitionsPass.php
  • symfony/framework-bundle/Command/ContainerLintCommand.php
  • symfony/http-kernel/Controller/ArgumentResolver/ServiceValueResolver.php
  • symfony/http-kernel/EventListener/ErrorListener.php

Minimal PHP Code Causing Issue

I've copied the symfony/http-kernel/Controller/ArgumentResolver/ServiceValueResolver.php to the demo.

The demo shows a different error to the one on my console: https://getrector.com/demo/dad0434f-b917-495d-8536-83b1f938a78b

Expected Behaviour

No error.

@samsonasik
Copy link
Member

Reproduced with 2 rules combined:

Rector\DowngradePhp81\Rector\StmtsAwareInterface\DowngradeSetAccessibleReflectionPropertyRector;
Rector\DowngradePhp80\Rector\Expression\DowngradeMatchToSwitchRector;

ref https://getrector.com/demo/3326a93d-b4a0-4ed3-8d9d-41767fe10a72

@malteschlueter
Copy link
Author

malteschlueter commented Oct 17, 2023

Thank you very much @samsonasik 👍
Rector processes now without any errors.

The downgraded Symfony has now some errors I need to investigate them i.e. the hash algorithm xxh128 which was introduced in PHP 8.1 is not available. I will try to create a new Rector downgrade rule for it.

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