Skip to content

chore(stan): burn down gds-mcp baseline (390 → 0)#25

Merged
oxyc merged 1 commit into
masterfrom
chore/stan-burndown-all
May 29, 2026
Merged

chore(stan): burn down gds-mcp baseline (390 → 0)#25
oxyc merged 1 commit into
masterfrom
chore/stan-burndown-all

Conversation

@oxyc

@oxyc oxyc commented May 29, 2026

Copy link
Copy Markdown
Member

Wipes the entire phpstan-baseline.neon file in one PR. New code is held to level 6 in CI with no baseline crutch. Closes #23.

How

The vast majority of errors came from missing iterable-value-type annotations on array PHPDocs. Most of the work happened by typing four traits in src/Concerns/, which then cascaded through every consuming class:

Trait Cascade
RestDelegation ~130 errors
Reversible 48 errors
BlockExamples ~10 errors
AcfAware ~2 errors

The remaining ~200 individual ability/integration methods were typed with a one-off add-phpdoc.js mod script that read PHPStan's raw output and inserted PHPDoc above each flagged signature using sensible defaults (array<string, mixed> for $input/$args/$body/etc., array<int, …> for lists). 196 PHPDoc lines added across 38 files. The handful of type mismatches PHPStan raised after the script (return shape was list not map; by-ref types too tight; menu items are \stdClass not WP_Post) were fixed by hand.

Real improvements caught at level 6

  • Plugin::$instance got a proper ?self $instance type (was bare protected static $instance)
  • SiteMapResource::buildMenuTree was passing nav-menu-item objects through wp_setup_nav_menu_item — typed as \stdClass now, with a comment noting WP_Post doesn't have those dynamic props
  • Multiple list-returning helpers (getDisconnectedPages, buildTree, getBlockStyles, parseMarkup, normalizeOperations) were declared as array<string, mixed> returns but actually emit list<...> — level 6 surfaced and forced the right shape

Verification

  • composer stan — 0 errors at level 6 with no baseline
  • composer test — 373 tests pass, 1734 assertions
  • composer lint:fix — Pint clean

🤖 Generated with Claude Code

Wipes the entire phpstan-baseline.neon file in one PR. New code is held
to level 6 in CI with no baseline crutch.

## Cascade structure

The vast majority of errors came from missing iterable-value-type
annotations on `array` PHPDocs. Most of the work happened by typing four
traits in `src/Concerns/`, which then propagated through every consuming
class:

  - RestDelegation::restGet/Post/Put + restResponseData + getRestListOutputSchema + getRestInputSchema + getRestItemOutputSchema  →  ~130 errors gone
  - BlockExamples::findBlockInstances/collectBlockExamples/structuralFingerprint/blockHasStyle + $structuralAttrs  →  ~10 errors
  - AcfAware::updateAcfFields  →  ~2 errors
  - Reversible::reversible  →  48 errors (cascaded through every Ability using it)

The remaining ~200 individual ability/integration methods were typed
with a one-off `add-phpdoc.js` mod script that read PHPStan's raw output
and inserted PHPDoc above each flagged signature using sensible defaults
(`array<string, mixed>` for $input/$args/$body/etc., `array<int, …>` for
lists). 196 PHPDoc lines added by the script across 38 files. The few
type mismatches PHPStan raised after the script (return shape was list,
not map; by-ref types too tight; menu items are stdClass not WP_Post)
were fixed by hand.

## Real improvements caught at level 6

- `Plugin::$instance` got a proper `?self $instance` type (was bare
  `protected static $instance`)
- `SiteMapResource::buildMenuTree` was passing nav-menu-item objects
  through wp_setup_nav_menu_item — typed as `\stdClass` now, with a
  comment noting WP_Post doesn't have those dynamic props
- Multiple list-returning helpers (`getDisconnectedPages`, `buildTree`,
  `getBlockStyles`, `parseMarkup`, `normalizeOperations`) were declared
  as `array<string, mixed>` returns but actually emit `list<...>` —
  level 6 surfaced and forced the right shape

## Verification

- `composer stan` — 0 errors at level 6 with no baseline
- `composer test` — 373 tests pass, 1734 assertions
- `composer lint:fix` — Pint clean (auto-formatted PHPDoc spacing)

Tracking issue #23 can be closed once this lands.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@oxyc oxyc merged commit 5004774 into master May 29, 2026
2 checks passed
@oxyc oxyc deleted the chore/stan-burndown-all branch May 29, 2026 20:11
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.

Burn down PHPStan level-6 baseline (390 errors)

1 participant