chore(stan): burn down gds-mcp baseline (390 → 0)#25
Merged
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Wipes the entire
phpstan-baseline.neonfile 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
arrayPHPDocs. Most of the work happened by typing four traits insrc/Concerns/, which then cascaded through every consuming class:The remaining ~200 individual ability/integration methods were typed with a one-off
add-phpdoc.jsmod 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\stdClassnotWP_Post) were fixed by hand.Real improvements caught at level 6
Plugin::$instancegot a proper?self $instancetype (was bareprotected static $instance)SiteMapResource::buildMenuTreewas passing nav-menu-item objects throughwp_setup_nav_menu_item— typed as\stdClassnow, with a comment notingWP_Postdoesn't have those dynamic propsgetDisconnectedPages,buildTree,getBlockStyles,parseMarkup,normalizeOperations) were declared asarray<string, mixed>returns but actually emitlist<...>— level 6 surfaced and forced the right shapeVerification
composer stan— 0 errors at level 6 with no baselinecomposer test— 373 tests pass, 1734 assertionscomposer lint:fix— Pint clean🤖 Generated with Claude Code