larastan / larastan

βš—οΈ Adds code analysis to Laravel improving developer productivity and code quality.
MIT License
5.48k stars 408 forks source link

Incompatible versions installed by composer due to tag/config (v1.* ... yeah, I know) #1949

Open EliW opened 4 months ago

EliW commented 4 months ago

Description

So yeah, this is a 'bug' report against an old version of Larastan, but it effected me today, might affect others, and should be an 'easy' fix. The problem is that the composer.json configuration of the v.1.x.x line of versions/tags, allows for incompatible versions of larastan & phpstan to be installed.

So I'm working on a legacy Laravel 8 codebase (and working to get it updated), but trying to get some cleanups/refactoring done first to make sure that transition happens smoothly. And so have been using larastan to check things. And I've now found where you made v1.0.4 purely as a 'fix' because of phpstan issues. Looks like phpstan 1.9+ stopped working with the v1 line ... that was detected, and v1.0.4 was push purely as a tag (not release) to fix that.

The problem is that v1.0.3...v1.0.0 were not changed. Which means the following happens:

If you install larastan first, in a Laravel 8 codebase. You get Larastan v1.0.4 ... and phpstan 1.8.11 ... and it works

However, if you install phpstan first, or already had phpstan installed, you get the latest version: phpstan 1.11.x

And if you THEN require larastan.... Composer looks at the various tags, sees that the v2 line can't work on Laravel 8 ... Sees that v1.0.4 doesn't work with phpstan 1.11 ... And then happily installs larastan v1.0.3 instead.

Which of course doesn't work / is broken.

So optimally, the tags v1.0.0 ... v1.0.3 should all be updated, to include the phpstan <1.9 directive, so the composer doesn't think it should work.

szepeviktor commented 4 months ago

Hello @EliW! πŸ‘‹πŸ»

There is no support for v1. But I leave you with this: composer update --with=phpstan/phpstan:1.8.11

EliW commented 4 months ago

Hello @EliW! πŸ‘‹πŸ»

There is no support for v1. But I leave you with this: composer update --with=phpstan/phpstan:1.8.11

Thanks @szepeviktor β€” Definitely understand that v1 is long dead. And you don't need the --with command, if you just remove phpstan then require larastan, it 'fixes' itself. (Unless another dependency had already installed a higher version).

I just wanted to bring this up, because it's an extremely minor 'fix', since it's not actually a code change at all. The 1.0.0, 1.0.1, 1.0.2, and 1.0.3 composer.json files just need the phpstan require section changed to be what is in the 1.0.4 tag as well.

While the 1.x line isn't supported, that 1 line JSON change in the 4 tags would stop composer from installing incompatible versions of larastan/phpstan together, which currently can happen. For people who are still stuck on Laravel 8, and who are trying to use larastan/phpstan to clean up the codebase to enable moving to 9/10/11 :)

Obviously y'alls call. It appears that the v1.0.4 tag was basically the fix for this, instead of updating the original tags. But unfortunately that doesn't fix it fully, since it only solves the issues in '1 direction'.