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

Downgrade errors #6845

Closed
ondrejmirtes opened this issue Dec 1, 2021 · 5 comments
Closed

Downgrade errors #6845

ondrejmirtes opened this issue Dec 1, 2021 · 5 comments
Labels

Comments

@ondrejmirtes
Copy link
Contributor

Bug Report

Subject Details
Rector version 0.12.5

I'm trying to downgrade https://github.com/ondrejmirtes/BetterReflection/tree/ng using this commit (ondrejmirtes/BetterReflection@24e6703) and running the following on the command line:

docker run --rm -it -w /app -v $(pwd):/app -w /app php:8.1.0-cli php -d memory_limit=2G vendor/bin/rector process src test -c build/downgrade-config.php

The project needs PHP 8.1 for some cases so that's why I'm running Rector through Docker.

I'm bumping into two issues that are printed at the end of the Rector run:

    ----------- end diff -----------


 [ERROR] Could not process "src/Reflection/ReflectionFunctionAbstract.php" file, due to:
         "Internal error.". On line: 46



 [ERROR] Could not process "src/SourceLocator/SourceStubber/PhpStormStubsSourceStubber.php" file, due to:

         "dirname(): Argument #1 ($path) must be of type string, bool given". On line: 174

Both look like some internal Rector errors.

You can reproduce the problem by running:

git clone [email protected]:ondrejmirtes/BetterReflection.git
cd BetterReflection
git checkout ng
composer install
docker run --rm -it -w /app -v $(pwd):/app -w /app php:8.1.0-cli php -d memory_limit=2G vendor/bin/rector process src test -c build/downgrade-config.php

Thanks.

@TomasVotruba
Copy link
Member

The first is reported by PHPStan internals.
Second will be similar cause.

Another issue might be with circular dependency of 2 different versions. E.g. Rector and PHPStan using different php-parser or in this case, better reflection.

@ondrejmirtes
Copy link
Contributor Author

Can you tell me how to show the full stack trace of the thrown exceptions?

@TomasVotruba
Copy link
Member

The --debug or -vvv should help.

@ondrejmirtes
Copy link
Contributor Author

Thank you, I was able to solve it. Rector now downgrades the codebase successfully. The key was to do the downgrading first, and renaming to the PHPStan namespace later.

I've had to do a few manual edits that the downgrading process wasn't able to do ondrejmirtes/BetterReflection@6bbb3c6 but right now it's fine. Thanks.

@TomasVotruba
Copy link
Member

Thanks for reaching out. I'm glad you find the way 👍

The key was to do the downgrading first, and renaming to the PHPStan namespace later.

Good to know.

The scoper is making 2 classes with class_alias() magic etc., that create ambiguous code, where analyses fails.
We do the same order in the workflow for Rector, as reference for future downgraders: https://github.com/rectorphp/rector-src/blob/70f4535cd336702571e5af138d0ee5ca38d8fff6/.github/workflows/build_scoped_rector.yaml#L62-L76

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

No branches or pull requests

2 participants