-
Notifications
You must be signed in to change notification settings - Fork 77
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 PHPStan at level 6 #637
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
These calls are dangerous but we can't change this without a BC break
Reserved memory will never be read from because it's only there to hold some memory, not to actually be used as a value
Both of these properties rely on a method being called before they will be set, otherwise they are null
Adding key/value types to everywhere we use 'array' is a huge job, so I've ignored these errors for now as there are >100 of them Ideally we would document what we actually mean by 'array' as some places do have distinct shapes that the array should conform to
FYI, once PHP5 support is dropped, types can be added to function arguments |
kattrali
approved these changes
Jan 31, 2022
This was referenced Jan 31, 2022
Merged
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Goal
PHPStan is a static analyser for PHP that can catch a bunch of potential bugs in code
This PR is based on #633, but runs at level 6 instead of max — PHPStan has 9 error levels (currently) that go from loosest (1) - strictest (9)
For the most part this is only changes to comments, but there are a couple of code changes too:
null
need an explicitreturn null
statement — a barereturn
or noreturn
at all are both errorsint
toini_set
and passingnull
topreg_match
are flagged as errors, so these have been fixedAdditionally, some errors have been ignored:
new static(...)
in a few places, which is unsafe as there's guarantee that child classes will share the same constructor signature (see this article). We can't fix this without a potential BC break, so have to ignore this for nowDesign
This PR stops at level 6 because this is where the levels become tricky to update to. Level 6 specifically adds checking for iterable types, e.g. a bare
array
should really bearray<KeyType, ValueType>
. I've turned this option off for now as we get around 100 errors from it, but this will be turned on in a future PR. Until then, I've not advanced any further as additional errors can appear as a consequence of adding stricter iterable typesTesting
PHPStan now runs on CI on both PHP 7.1 & 8.1