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

Add support for Laravel 9 #213

Merged
merged 33 commits into from May 2, 2022
Merged

Add support for Laravel 9 #213

merged 33 commits into from May 2, 2022

Conversation

Nielsvanpach
Copy link
Contributor

@Nielsvanpach Nielsvanpach commented Jan 19, 2022

I don't think it' possible to add Laravel 9 support without dropping 7.3 and 7.4 support.

Current issues

Hopefully if this is fixed, all the dependency issues are solved and we can work on proper Laravel 9 compatibility.

@Nielsvanpach Nielsvanpach changed the title Laravel 9 Add support for Laravel 9 Jan 19, 2022
composer.json Show resolved Hide resolved
Copy link
Contributor

@caugner caugner left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good initiative, but I would suggest only adding 9.x to the illuminate_version matrix for now.

Previously, the tests were testing the lowest and highest version of each Laravel major version, but I don't think the status quo of this PR still does that.

.github/workflows/test.yml Outdated Show resolved Hide resolved
composer.json Outdated Show resolved Hide resolved
.github/workflows/test.yml Outdated Show resolved Hide resolved
illuminate_version: [6.*, 8.*]
composer_flags: ['', '--prefer-lowest']
illuminate_version: [6.*, 7.*, 8.*, 9.*]
stability: [prefer-lowest, prefer-stable]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

--prefer-stable is not the opposite of --prefer-lowest, it also makes sense in combination.

Actually, I think that --prefer-stable is even the default, but I'm not totally sure.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indeed, both can be used in combination I think. prefer-stable will check for packages with minimum-stability set to stable. But I don't think it's the default (and if so, it's still explicit this way). It's just an extra check to see if this package is easily installable, feel free to improve if possible!

@zlodes
Copy link

zlodes commented Feb 9, 2022

I think we need to remove restrictions of barryvdh/laravel-ide-helper, because these versions don't require laravel/framework: ^9.0

@caugner
Copy link
Contributor

caugner commented Feb 10, 2022

I think we need to remove restrictions of barryvdh/laravel-ide-helper, because these versions don't require laravel/framework: ^9.0

Indeed, this seems to be the big blocker going forward.

As an alternative, #204 discusses supporting the latest laravel-ide-helper and mentions a fork which achieved that. However, that fork has not been updated since August 2021.

Due to limited resources, I will probably have to migrate at least one of my Laravel projects to larastan (maintained by Nuno who works for Laravel), because it requires Laravel 9 asap.

@zlodes
Copy link

zlodes commented Feb 11, 2022

@caugner Larastan now (^2.0) has several nasty bugs with generics. :|

We use phpstan and psalm together because it increases global code quality. Nowadays the functionality difference between psalm and phpstan is very huge, but it's not bad, v.v. it's cool that these tools are improving.

@canvural
Copy link

@caugner Larastan now (^2.0) has several nasty bugs with generics. :|

What are those nasty bugs? Maybe we can fix them if you open an issue 😊

@zlodes
Copy link

zlodes commented Feb 13, 2022

@canvural sorry. I meant phpstan issues, e.g.: phpstan/phpstan#6505

And if I update Larastan to ^2.0 something around generics will broken.
We use Psalm and PhpStan together and now it seems that we need to release psalm-plugin-laravel because of many changes in Laravel 9.0. And then it will be possible to use Larastan ^2.0 and Psalm.

@HDVinnie
Copy link

Any timeline on when Laravel 9 will be supported?

@mr-feek
Copy link
Collaborator

mr-feek commented Feb 14, 2022

@HDVinnie if a PR is made with green CI, I'll happily merge! I don't have the time to figure it out myself right now

@Nielsvanpach
Copy link
Contributor Author

Nielsvanpach commented Feb 14, 2022

Status update

Hopefully if this is fixed, all the dependency issues are solved and we can work on proper Laravel 9 compatibility.

@mzur mzur mentioned this pull request Feb 16, 2022
20 tasks
@tm1000
Copy link
Contributor

tm1000 commented Feb 16, 2022

Due to limited resources, I will probably have to migrate at least one of my Laravel projects to larastan (maintained by Nuno who works for Laravel), because it requires Laravel 9 asap.

This is really unfortunate. You are a maintainer of this project and yet you are essentially abandoning it and moving to phpstan because you don't have the time to maintain it.

I'm not trying to start a fight here but it was rather shocking to read that. To not have time to maintain this is one thing but to just abandon even trying to fix it and move to another product is a whole other thing and compromises the ability for people to use Psalm in Laravel which ultimately hurts Psalm in the end.

The fork (https://github.com/brokeyourbike/psalm-plugin-laravel) itself exists because #204 is still not solved (and for some reason the fork shows up on the Psalm site as a supported plugin which is further confusing and fragmenting to the community as a whole). #204 should have been solved a while ago. Maintain two separate versions. The fork exists because the fork dropped support for Laravel 6. This project could do the same by just maintaining two separate versions. I mean heck there hasn't even been a release of this in the last 8 months so it really doesn't effect anyone to have two versions of this.

The longer this process drags out (Not supporting the new IDE helper/writing your own) and not supporting Laravel 9 the more this plugin prevents people from using Psalm with Laravel. Laravel already supports PHPStan because a core developer of Laravel wrote the plugin himself.

To me the outcome is obvious. If you want to use Laravel 9 then do not use Psalm, use phpstan. Or wait until someone does another fork that supports Laravel 9...then 10 and so forth.

@HDVinnie if a PR is made with green CI, I'll happily merge! I don't have the time to figure it out myself right now

I'm sorry but the master branch doesn't even pass these requirements! See: https://github.com/psalm/psalm-plugin-laravel/runs/5188633439?check_suite_focus=true

However, that fork has not been updated since August 2021.

This project hasn't had a release since July 2021. Why does this matter?

Open Source is hard. Especially when you aren't getting paid. But watching the outcome of #204 thus far (which was essentially "we need to write our own and not use ide-helper but we don't have time") and that going no-where worries me for when this will support Laravel 9 (if ever)

@Nielsvanpach
Copy link
Contributor Author

Nielsvanpach commented Feb 17, 2022

So basically you are disappointed that someone no longer has (unpaid) time to support an open source project you rely on and you feel the need to let that person know that it shocks you? 🙃

@tm1000
Copy link
Contributor

tm1000 commented Feb 17, 2022

No. It's shocking that one of the maintainers said he has no time to work on this so he's going to use another project instead. That should not have been said. Anyone who comes here for help will see that and think to themselves why use this"

If the maintainer no longer has time then they should say "we need more help". Instead it's "we don't have time. patches welcome if you get CI to pass!" Do you not see an issue with that? Both maintainers said they have no time to maintain the project they are maintaining.

CI literally isn't even passing on the master branch and it hasn't for a while. The fact that a maintainer said patches welcome if you get CI to be green is strange because it's not even green right now

There have been several proposed fixes to support new ide helper and all have been rejected because of the continued need to support laravel 6.0 even though one could just do a sem ver release of a new major version.

The fork that exists is also an issue because it violates packagist.org guidelines which state that one should not publish packages that are forks. Yet it exists in packagist.org and additionally it's listed on the psalm site.

The reasoning the fork exists in the first place is because this project can't find a solution for a long standing issue in regards to ide helper. That's a big big issue in itself. That guy went off and forked it because he say that a solution was unattainable in this project. This will keep happening I'm sure. Especially with laravel 9. I'm trying to bring awareness that saying "I'm moving to phpstan" will just cause more of these forks.

I work on the language server engine for psalm and also I'm the maintainer for the vscode plug-in for psalm. So I do my fair share of unpaid open source development. I'm just confused by responses like "I'm moving to phpstan. Patches welcome" from a maintainer.

I wouldn't have even commented on this if the comment about "I'm switching to phpstan" from a maintainer wasn't said.

@canvural
Copy link

I don't think @caugner is a maintainer of this project. He just contributes a lot. So it's totally fine if he says he will not work on this.

@tm1000
Copy link
Contributor

tm1000 commented Feb 17, 2022

@canvural and then yes. I am totally wrong. I accept that and I apologize. The appearance from issues and PRs is that he was a maintainer not just a contributor.

However maybe this project needs more than one maintainer if the solution from a very active contributor is "I'm moving to phpstan"

I think I've stirred the pot a bit much here and I'm sorry for that. Thanks for your work here @Nielsvanpach and for the packages @spatie provides.

@tm1000
Copy link
Contributor

tm1000 commented Apr 7, 2022

@Nielsvanpach Ok this PR (Nielsvanpach#2) fixes the tests (except for 1 or 2....maybe?) and also fixes the merge conflict with master

@tm1000
Copy link
Contributor

tm1000 commented Apr 7, 2022

Ok so this should be a little easier for someone to fix (if not me).

The failing tests are due to php 8.1 incpompatibilies when using prefer-lowest because the issues were made in as a non-breaking change in the same release.

Additionally in Laravel 9 more specific models are returned rather than just Model itself so the tests need to be adjusted to reflect that for Laravel 9 as opposed to 8

Copy link
Contributor

@mzur mzur left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there any specific reason why the tests for firstOrCreate(), firstOrNew() and factory() were removed? These can still be used in Laravel 9.

Edit: Now I see that the tests no longer make sense because of the removed Laravel versions.

@mzur
Copy link
Contributor

mzur commented Apr 26, 2022

I created a PR to this branch that should fix the remaining failing tests. Does anyone have a better idea to fix the PHP 8.1 issues than to require-dev working versions of the incompatible packages?

@tm1000
Copy link
Contributor

tm1000 commented Apr 26, 2022

Thanks @mzur !

Fix failing tests for firstOrCreate, firstOrNew and PHP 8.1
@mzur
Copy link
Contributor

mzur commented Apr 27, 2022

All checks are green now so this may be ready to merge?

@tm1000
Copy link
Contributor

tm1000 commented Apr 27, 2022

@mzur thanks for getting it the final way there!

@Nielsvanpach Nielsvanpach marked this pull request as ready for review April 27, 2022 06:52
use RuntimeException;

/**
* Duplicate of https://github.com/psalm/codeception-psalm-module
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey could you help me understand why we need this duplicated? Do we need some changes merged upstream to codeception-psalm-module? @weirdan has been great at merging prs fast! Let me know

Copy link
Contributor

@tm1000 tm1000 Apr 27, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's duplicated because of the changes to codeception. Doing the PR against https://github.com/psalm/codeception-psalm-module would require a newer version of codeception which doesnt support PHP 7.x.

See: https://www.diffchecker.com/kbix1BTd

Specifically params that were strings are now PyStringNode object and additionally, exit codes are now integers instead of strings

Copy link
Contributor

@tm1000 tm1000 Apr 27, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just went through https://github.com/psalm/codeception-psalm-module and unfortunately even checking it out and running the tests there without doing any code modifications there are 13 unit test failures.

The issue is with the deprecated usage of totallyTyped and yes usually Weirdan is quick on PR changes but @mzur already did a PR for this back in February which is still not merged. psalm/codeception-psalm-module#39

@@ -8,40 +8,11 @@ jobs:
strategy:
fail-fast: false
matrix:
php: [7.3, 7.4, 8.0, 8.1]
illuminate_version: [6.*, 8.*]
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be great if we could support all versions in the same major release (1.x) -- Could you help me understand what might be a breaking change not allowing us to support these still? (I want to continue supporting laravel 6 til EOL, which is in september).

Copy link
Contributor

@tm1000 tm1000 Apr 27, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think it' possible to add Laravel 9 support without dropping 7.3 and 7.4 support.

Laravel 6 won't work well on php 8. It's certainly not supported. That's why I believe laravel 6 support was dropped.

Is there a major issue with just issuing a 2.0 release for this PR? I don't understand the hesitation at doing a split release as has been already mentioned in this PR previously. See: #213 (comment)

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Larastan (Laravel plugin for PHPStan) also released a new major version for Laravel 9.

Main reason we have a major version increase is we dropped support for Laravel versions older than 9. Because now all the Collection stubs Larastan had are moved to the Laravel core!

Copy link
Collaborator

@mr-feek mr-feek Apr 27, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My hesitation is just more maintenance overhead -- I would think we could solve that by adjusting the test matrix to not run laravel 6 on php 8 (like we are already doing with other tests) .

It's not a blocker, would just like to understand what exactly is causing the need for multiple versions

@mr-feek
Copy link
Collaborator

mr-feek commented Apr 27, 2022

Thanks for the hard work everyone! Give me a day or two to figure out how best to merge + maintain this, but expect it to be merged + released soon :)

"slevomat/coding-standard": "^6.2"
"phpoption/phpoption": "^1.8.0",
"symfony/http-foundation": "^5.3.7 || ^6.0",
"ramsey/collection": "^1.2.0"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

curious what we need this for? I don't see it referenced in the code

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know that if ramsey/collection is less than 1.2.0 it blows up on PHP 8.1 tests because Return Type will Change errors.

Copy link
Contributor

@mzur mzur Apr 27, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These were all the packages that didn't work with PHP 8.1 at prefer-lowest. I didn't know any better than to require the versions compatible with PHP 8.1 to fix the failing tests. The main issue is the breaking change of return type checks in the minor release of PHP and all these packages claiming to work with PHP ^8.0 although they are not.

composer.json Outdated
@@ -46,6 +50,7 @@
},
"scripts": {
"analyze": "psalm",
"analyse": "psalm",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this looks accidental

Fix accidental script declaration in composer.json
@mr-feek mr-feek merged commit 7524304 into psalm:master May 2, 2022
@mr-feek mr-feek added the enhancement New feature or request label May 2, 2022
@mr-feek
Copy link
Collaborator

mr-feek commented May 2, 2022

Thanks for the PR! cutting a new major release, 2.0

@Nielsvanpach Nielsvanpach deleted the laravel-9 branch May 3, 2022 07:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

10 participants