Repository navigation
chore(phpstan): raise the analysis from level 5 to level 8 - #45
Merged
Merged
Conversation
This file contains hidden or 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
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.
Branch
chore/phpstan-level, basemain. One commit per level, each recorded withvendor/bin/pollora-qa ratchet --update(it also reorders the keys of.harness.json).Changes
Level 6: PHPDoc only (value types of the clause arrays and of the array parameters).
Level 7:
newWpQuery()implementations document the query class they return;PostQuery::ids()maps through a typed closure; the date builder'sget()PHPDoc admitsinclusive => true.Level 8: the date builder's private shapes admit the nullable values;
PostQuery::ids()tolerates a nullposts.Wider public return PHPDoc:
ComparisonBuilder::buildConfig(),MetaQueryBuilder::get()andDateQueryBuilder::get()now sayarray<string, mixed>; the old types left out values the code returns (a meta value of any type,inclusive => true).No native signature, no query argument changes.
Level 9 (not done): what it needs
33 errors remain at level 9. The blocker is a public contract:
CommentQuery,NetworkQuery,SiteQuery,TermQuery,UserQuery::get(),Term\Retrieval, two inUser\Retrieval; nine reports) passarray<string, mixed>to constructors the WordPress stubs type with array shapes.getArguments()is public, shared byBuildsArgumentsand built bypollora/wordpress-args: it would need a shape per query class (or typing in wordpress-args). An@var, anignoreErrorsor a baseline entry would only hide it.first()returns what WordPress returns (mixed),TermQuery::names()/slugs()andUserQuery::pluck()declarearray<string>.statekey of a sub-query (mixedused as an array key,QueryBuilderandTraits\Query\SubQuery), theintval(...)callbacks ofids(), theDateQuery::applyInclusive()argument.Checked
--prefer-lowest(phpstan 2.3.2, wordpress-args 1.1.0, phpstan-wordpress 2.0.0), where the tests pass too.composer qa:fastandcomposer qapass (macOS, PHP 8.4); 442 tests, 1 incomplete.check --coverage --mutation: coverage 97.8 %, MSI 93.45 % (floors 97.12 / 93, unchanged).roave-backward-compatibility-checkagainstmain, run on the level-8 code before a last one-token change inside a method body: no break.Not verified