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

Fix/update PHPStan #212

Merged
merged 6 commits into from
Nov 8, 2021
Merged

Fix/update PHPStan #212

merged 6 commits into from
Nov 8, 2021

Conversation

drupol
Copy link
Collaborator

@drupol drupol commented Nov 1, 2021

This PR:

  • Fix PHPStan 1.0 new issues (because of updated level 8)
  • Update baselines and remove obsolete PHPStan issues thanks to new features in PHPStan 1.0
  • Update baselines and append new errors detected by PHPStan 1.0
  • Fix PHPStan to level 8
  • Find why PHPStan fails on PHP 7.4 and not on 8 - Fixed by disabling reportUnmatchedIgnoredErrors

Fixes #210

@AlexandruGG
Copy link
Collaborator

Hey, for this:

Find why PHPStan fails on PHP 7.4 and not on 8 - Maybe we should disable tests on PHP 7.4 ?

Looks like all the failures are related to ignored errors which are actually not found in the code on 7.4. To silence those errors we could just use this config option reportUnmatchedIgnoredErrors: https://phpstan.org/user-guide/ignoring-errors#reporting-unused-ignores

@drupol drupol marked this pull request as ready for review November 2, 2021 21:16
message: "#^Parameter \\#1 \\$callable of class loophp\\\\collection\\\\Iterator\\\\ClosureIterator constructor expects callable\\(\\.\\.\\.mixed\\)\\: iterable, Closure\\(Generator\\)\\: Generator\\<mixed, mixed, mixed, void\\> given\\.$#"
count: 1
path: src/Collection.php

Copy link
Collaborator

Choose a reason for hiding this comment

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

@drupol I'm a bit concerned by the high number of new errors this is adding to the baseline. This is likely due to PHPStan's new level 9, which is quite brutal, similar to Psalm's level 1 which disallows mixed (which we are not using - this this project uses the default Psalm level 2).

This PR is currently trying to do 2 things at the same time, and I think we should separate them:

  • updating to PHPStan 1.0 -> we should be able to do this and fix any errors as long as there aren't too many

  • updating to PHPStan level 9 -> I don't think we can do this yet, it might take quite a bit of work to get the static analysis in place properly for this. For now I think we should limit the level to 8 in the grumphp config for this project only

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Right, I had this in mind as well at the beginning, then I skipped it.

I will update the PR accordingly in the evening.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Job done!

Comment on lines -9 to -21
message: "#^PHPDoc tag @template T for class loophp\\\\collection\\\\Contract\\\\Operation\\\\Unpackable with bound type array\\<int, NewT\\|NewTKey\\> is not supported\\.$#"
count: 1
path: src/Contract/Operation/Unpackable.php

-
message: "#^PHPDoc tag @template T for interface loophp\\\\collection\\\\Contract\\\\Operation\\\\Unpackable with bound type array\\<int, NewT\\|NewTKey\\> is not supported\\.$#"
count: 1
path: src/Contract/Operation/Unpackable.php

-
message: "#^PHPDoc tag @template T for class loophp\\\\collection\\\\Operation\\\\Unpack with bound type array\\<int, NewT\\|NewTKey\\> is not supported\\.$#"
count: 1
path: src/Operation/Unpack.php
Copy link
Collaborator

Choose a reason for hiding this comment

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

something good came out of this 😄

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Definitely ! :)

Copy link
Collaborator

@AlexandruGG AlexandruGG left a comment

Choose a reason for hiding this comment

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

We'll need to see how we can fix the new baseline errors, I'll probably look into it when I get the time

@drupol drupol merged commit 88493b1 into master Nov 8, 2021
@drupol drupol deleted the fix/update-phpstan branch November 8, 2021 08:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

PHPStan 1.0 upgrade
2 participants