Skip to content

chore: PHPStan level max, with no baseline - #24

Merged
ogorzalka merged 3 commits into
mainfrom
chore/phpstan-max
Nov 27, 2026
Merged

ogorzalka merged 3 commits into
mainfrom
chore/phpstan-max

Conversation

@ogorzalka

@ogorzalka ogorzalka commented Nov 27, 2026 •

Copy link
Copy Markdown
Member

PHPStan goes from level 5 to max (about 190 errors at the start), with no baseline, no new ignore and no @var added to quiet it. The two inline @var casts of the configuration are removed, and the Contact Form 7 ignore pattern is replaced by a small stub (tests/Stubs/phpstan/). No setting, command, hook, route or payload of the HTTP contract changes.

What changes on damaged or unexpected data

  • An array or an object where text or a number is expected (option, database row, filter, plugin) reads as '' or 0 (new Domain/Scalar), never as Array or 1.
  • Media: a width, height, filesize or duration that is not a number is null; sizes.full needs both measures.
  • Rows, menu items, forms, form tags and WPML translations that cannot be read are left out. An old-slug row with no post ID no longer reaches get_post(), which would answer with the current post.
  • The preview overlay replaces a title, content or excerpt that is not an object instead of failing on it.
  • A headless/search/args filter that returns neither an array nor a string is ignored (the endpoint's own arguments are used).
  • wp headless token create|rotate and wp headless schema openapi refuse an option given as a list; a GraphQL schema that is not text is an error.
  • Pollora: a pollora.headless configuration that is not an array raises InvalidSettingsException (booting with no settings would leave the front open); a hook service without add() raises HookServiceException.
  • No $wpdb: the redirect sources and the pending events answer with an empty list.

To check

  • The security patterns gate (SEC-05) was already failing on main, hidden by observe mode. The Rank Math sources are now read with unserialize(..., ['allowed_classes' => false]) and the nosemgrep comment with its reason that the sibling packages use. This is the only suppression added: please confirm you accept it.
  • The three SQL queries name their tables with %i (needed for the literal-string check of prepare()), so the package needs WordPress 6.2 or later. No minimum was declared until now.
  • render_block() receives the same block as before, with its five known keys checked.
  • .harness.json still records phpstan_level: 5: recording max is left to a maintainer.

Olivier Gorzalka added 3 commits November 27, 2026 16:55
Values from options, the database, filters and plugins are checked where they
are read. The two inline @var casts are gone. Contact Form 7 gets a small
PHPStan stub in place of an ignored pattern.
@ogorzalka
ogorzalka merged commit f15edd9 into main Nov 27, 2026
12 checks passed
@ogorzalka
ogorzalka deleted the chore/phpstan-max branch November 27, 2026 16:19
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