Skip to content

refactor(types): raise PHPStan from level 5 to max - #19

Merged
ogorzalka merged 6 commits into
mainfrom
chore/phpstan-above-5
Nov 26, 2026
Merged

ogorzalka merged 6 commits into
mainfrom
chore/phpstan-above-5

Conversation

@ogorzalka

Copy link
Copy Markdown
Member

Branch: chore/phpstan-above-5. Stacked on fix/delete-multiple-invalid-key: merge that PR first.

What changes

One commit per level, no baseline, no ignore, then one test commit.

  • 6: the $seen storage of IncompleteObjects is documented with the value type it has.
  • 7: ValueCodec documents $allowedClasses as bool|list<string> (what Settings gives it).
  • 8: configuration only.
  • 9: mixed values are narrowed before they are cast (Settings, PhpRedisConnector::credentials(), Manager, Environment, WordPressObjectCache).
  • max: Redis::OPT_THROW_ON_ERROR is read by name and checked; Environment::current() keeps only the string keys of $_SERVER and $_COOKIE.

No signature, hook, command or configuration key changes (public surface gate: unchanged).

Behaviour differences, only for values of the wrong type

  • A setting that is not a scalar (an array, an object without __toString()) now takes its default. Before, it was cast ("Array", 1) or raised an error.
  • A Redis password or user name without a text form counts as missing; a password of false no longer sends an empty AUTH.
  • A lifetime, step or blog ID that is not a scalar counts as 0 (before: 1 for a non-empty array).

Ratchet

Each level was recorded with vendor/bin/pollora-qa ratchet --update --metric=type_coverage:94.4 (phpstan_level 5 -> "max"). The tool also re-encodes the file (msi 96.0 -> 96, services moves after ratchet); no other value changes. The type coverage floor stays at 94.4 although the tool measures 100.

What this proves

  • phpstan analyse at level max: 0 errors (run with PHP 8.4 and 8.3).
  • roave-backward-compatibility-check --from=v0.3.1 (QA-05, run locally): no backwards-incompatible change.
  • composer qa:fast passes. In composer qa: code style, static analysis, Rector, dependency policy and analysis, audit, public surface, archive and ratchet pass.

What this does not prove

  • composer qa is not green locally: the tests gate has one failure, ManagerTest > it is not healthy without the drop-in..., because the machine has no phpredis (not checked instead of unreachable: ...). The same failure happens on an untouched main.
  • 255 tests that need Redis are skipped locally, so line coverage (floor 100) was not measured. The new test of credentials() lives in PhpRedisConnectorTest, which is skipped as a whole without Redis; its assertions were run separately and pass.
  • Mutation score (floor 96) cannot be measured here: without Redis the run (with ManagerTest set aside) gives 90.49 %. In that run no surviving mutant is on a line this branch changes, but the Redis-only lines (PhpRedisConnector) are not mutated at all.
  • Semgrep is not installed locally (SEC-*, CONV-10).
  • Local harness is v0.1.36 (installed from the constraint); the workflow pins @v0.1.35.

@ogorzalka
ogorzalka changed the base branch from fix/delete-multiple-invalid-key to main November 26, 2026 09:38
@ogorzalka
ogorzalka merged commit d6f2acc 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