Skip to content

refactor(types): analyse ArgumentHelper at PHPStan level max - #25

Merged
ogorzalka merged 6 commits into
mainfrom
chore/phpstan-level-up
Nov 26, 2026
Merged

ogorzalka merged 6 commits into
mainfrom
chore/phpstan-level-up

Conversation

@ogorzalka

Copy link
Copy Markdown
Member

Branch chore/phpstan-level-up, base main. Six commits: the baseline entry, then one per level (6 to 10).

The finding

The baseline entry said "Trait ArgumentHelper is used zero times and is not analysed". src holds only that trait, so PHPStan analysed nothing: level 5 (and 6 to 10) were green without reading a line.

What changes

  • The class the tests already used (TestClass) moves, now typed, to tests/Fixtures/TestClass.php; that directory joins the analysed paths, so the trait is analysed. The test file requires it; tests and assertions are unchanged.
  • phpstan.neon no longer includes phpstan-baseline.neon (with it included, the now unmatched entry fails the run).
  • src/ArgumentHelper.php: PHPDoc only. @var args (an unknown class) becomes array<array-key, mixed>|null; array value types are added. No signature or behaviour change.
  • Level 5 to max; ratchet recorded with vendor/bin/pollora-qa ratchet --update --metric=phpstan_level:N --metric=type_coverage:88.8 (the second flag keeps the floor rounded down to one decimal; the tool would otherwise write 88.89).

Left for a maintainer (protected file, QA-02)

The ratchet still counts the 1 entry of the file nothing includes any more:

cd wordpress-args
git rm phpstan-baseline.neon
vendor/bin/pollora-qa ratchet --update --metric=phpstan_baseline:0 --metric=type_coverage:88.8

Checked (PHP 8.4, macOS)

  • PHPStan level max: 0 errors, trait analysed in the context of TestClass.
  • Pest: 12 passed, 13 assertions; the moved class aside, the test file is unchanged (same 5 tests).
  • composer qa:fast and composer qa: every gate that ran passed. Line coverage 100 %, mutation score 91.67 % (floor 85).
  • QA-05 (roave-backward-compatibility-check --from=2.0.0, in a local clone): no backwards-incompatible change.
  • pollora/entity (which uses the trait), with this file copied into its vendor: PHPStan level 8 on src 0 errors, tests pass.

Not verified

  • The framework downstream job and pollora/query (which also uses the trait) were not run.
  • Semgrep not installed.

Pollora maintainer added 6 commits November 26, 2026 09:51
…ng unused

PHPStan skips a trait that no analysed class uses, so nothing in src was analysed. The class the tests use moves to tests/Fixtures, which joins the analysed paths; the baseline is no longer included. The one real report, an unknown type in a @var, is fixed.
Value types of the arrays of ArgumentHelper, in PHPDoc only.
No code change needed beyond the PHPDoc of level 6.
@ogorzalka
ogorzalka merged commit 86d2870 into main Nov 26, 2026
10 checks passed
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.

1 participant