Skip to content

chore(qa): raise PHPStan to level 7 - #56

Merged
ogorzalka merged 9 commits into
mainfrom
chore/phpstan-level-7
Nov 25, 2026
Merged

ogorzalka merged 9 commits into
mainfrom
chore/phpstan-level-7

Conversation

@ogorzalka

Copy link
Copy Markdown
Member

Branch: chore/phpstan-level-7, stacked on chore/phpstan-level-6. It carries the two bug fixes below as cherry-picked commits (b9f5bd1, a5b94be): merge their PRs first, or this one carries them.

What changed

about 45 errors (19 in src/, 26 in tests/):

  • 2 real bugs, each in its own PR with a test that fails without it: lot5-hook-fix-invokable.md (invokable objects / Class::method strings in argument detection: TypeError), lot5-hook-fix-nonpublic.md (a non-public handler method was retried tries times).
  • $wpdb in Recovery::recover() / UniqueLock::prune(): declared \wpdb|null (@var on the global, which has no declared type; the runtime is_object() guard is kept so the test doubles still work). wpdb::prepare() wants a literal string and the query interpolates {$wpdb->options}, the table name, which no placeholder can replace before WordPress 6.2's %i: two @phpstan-ignore argument.type (reason), reason on the line. Every value goes through a placeholder.
  • Captured values and hook arguments: PHPDoc widened from array<string, mixed>/array<int, mixed> to array<int|string, mixed> (AsyncPayload, AsyncContext, AsyncDispatcher): the code never enforced string keys, and the variadic QueuedHandler::__invoke(mixed ...$arguments) carries named arguments through. Doc only.
  • AbstractHook::replaceTrackedCallback() updates a local copy of the registrations then assigns it (same result); function names are read through ReflectionFunction(Closure::fromCallable(...)); resolveClassMethodCallback() takes a class-string.
  • tests: json_encode(..., JSON_THROW_ON_ERROR) (the string|false the tests passed on), and a few reads that assumed the shape of a registration.

Checked

0 errors at level 7; pest 555 pass + 1 incomplete; composer qa passes (line coverage 95.9 %, recorded 93.05).

Not verified

Semgrep not run (SEC-03 on the two $wpdb queries, unchanged text, not re-scanned); mutation not measured; WordPress suite not run.

@ogorzalka
ogorzalka changed the base branch from chore/phpstan-level-6 to main November 25, 2026 12:35
@ogorzalka
ogorzalka merged commit 3a14ca4 into main Nov 25, 2026
15 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