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

Rector requires phpstan 0.12.93 #6608

Closed
devbanana opened this issue Aug 3, 2021 · 10 comments
Closed

Rector requires phpstan 0.12.93 #6608

devbanana opened this issue Aug 3, 2021 · 10 comments
Labels

Comments

@devbanana
Copy link

devbanana commented Aug 3, 2021

Bug Report

Subject Details
Rector version 0.11.42

I have phpstan 0.12.94 installed. However, when I attempt to install rector/rector with composer, it complains because it will not accept anything higher than phpstan 0.12.93. I've tried this on multiple projects.

Minimal PHP Code Causing Issue

With phpstan 0.12.94 installed, running:

composer require rector/rector —dev

throws an error.

Expected Behaviour

I should be able to install the package successfully.

@devbanana devbanana added the bug label Aug 3, 2021
@TomasVotruba
Copy link
Member

TomasVotruba commented Aug 3, 2021

Hi, this is expected, see composer.json:

"phpstan/phpstan": "0.12.93"

First, Rector needs to be tested and upgraded to newer PHPStan. In the past we had this version opened and it started to crash on PHPStan BC break. Now we got the safer way, to keep our users stable :)

Feel free to send PR to upgrade composer.json version, often it's an easy pick :)

@samsonasik
Copy link
Member

Fixed at rectorphp/rector-src#585

@enumag
Copy link
Contributor

enumag commented Sep 2, 2021

In case someone finds this issue later, it's still possible to force installation of newer phpstan than rector allows at the given moment. For instance at the time of writing latest rector 0.11.52 requires phpstan 0.12.96 while the latest is 0.12.98. Yet I was still able to force it using this trick in composer.json:

        "phpstan/phpstan": "0.12.98 as 0.12.96",
        "rector/rector": "^0.11.52",

@enumag
Copy link
Contributor

enumag commented Sep 2, 2021

@TomasVotruba This might possibly be worth mentioning in the readme for those who know what they're doing. What do you think?

On a side note do you think phpstan version might be open again after phpstan 1.0 is out which should hopefully be more stable and not cause bc breaks anymore?

@devbanana
Copy link
Author

This is useful, thanks for sharing.

@TomasVotruba
Copy link
Member

The issue is conflict in shared non-prefixed PHPParser namespace. Each project has their own, so it's a race condition issue.

@enumag
Copy link
Contributor

enumag commented Sep 2, 2021

@TomasVotruba Not sure I understand. You mean there is one PHPParser installed normally as phpstan dependency and another one bundled into rector? If that's the case then why does Rector contain a copy when the parser will be there as a dependency anyway? 🤔

@enumag
Copy link
Contributor

enumag commented Sep 2, 2021

Ah yeah... rector's vendor directory contains non-prefixed nikic/php-parser as well as phpstan while also requiring them again as dependency... I understand that you need to require them in composer.json in order to prevent incompatible versions but imo they shouldn't be in the vendor directory. Ideally the vendor directory should strictly contain only prefixed packages. Is there some reason for having them there or can we remove them?

@TomasVotruba
Copy link
Member

That's does not solve the problem.

@TomasVotruba
Copy link
Member

Ideal solution is to unpack PHPStan and merge it's composer.json to Rector's. That way their dependencies are shared. Still requires version lock.

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

4 participants