Skip to content

feat(phpstan): promote to level 7 - #24

Merged
rpgmem merged 1 commit into
mainfrom
claude/phpstan-level-7
Apr 16, 2026
Merged

feat(phpstan): promote to level 7#24
rpgmem merged 1 commit into
mainfrom
claude/phpstan-level-7

Conversation

@rpgmem

@rpgmem rpgmem commented Apr 16, 2026

Copy link
Copy Markdown
Owner

Why

Level 6 was clean (empty baseline), so this promotes to level 7 for stronger null-safety analysis on all new code.

What changed

  • 164 null-safety fixes across 51 source files:
    • 122 argument.typestring|false?: '', (string) casts, is_string() guards
    • 29 return.typeob_get_clean() ?: '', wp_json_encode() ?: ''
    • 11 offsetAccess.notFound$arr['key'] ?? '' for optional array keys
    • 1 offsetAccess.invalidOffset + 1 assign.propertyType
  • 20 @phpstan-ignore-next-line for $wpdb->prepare() literal-string false positives (dynamically built SQL from trusted internal logic — standard WP pattern)
  • 1 real bug found and fixed: class-ffc-form-cache.php:328 referenced 'FFC_Form_Cache' (non-existent class) instead of the namespaced FormCache
  • Baseline generated with 518 remaining WP-idiom errors (property.notFound, method.notFound on stdClass from $wpdb->get_row() / get_results()) — these require per-callsite docblock annotations, out of scope for this sprint
  • Level bumped: 6 → 7 in phpstan.neon.dist

Verification

vendor/bin/phpstan analyze  →  [OK] No errors
vendor/bin/phpunit          →  OK (3165 tests, 7439 assertions)

Test plan

  • PHPStan (PHP 8.1) green
  • PHPUnit (PHP 8.1 / 8.2 / 8.3 / 8.4) all green
  • Composer audit green
  • Verify minified assets green

- Fixed 164 null-safety issues (argument.type, return.type, offsetAccess.*)
  across 51 files, including:
  - 122 argument.type (strtotime ?: time(), wp_json_encode ?: '', esc_attr
    coercions, fopen guards, get_permalink ?: '', etc.)
  - 29 return.type (ob_get_clean ?: '', int casts on $wpdb->query, etc.)
  - 11 offsetAccess.notFound (?? '' for optional array keys)
  - 1 offsetAccess.invalidOffset (float|int key cast)
  - 1 assign.propertyType (tightened constructor type)
- Added 20 @phpstan-ignore-next-line for $wpdb->prepare() literal-string
  false positives (dynamically-built SQL from trusted internal logic)
- Added baseline for 518 remaining WP-idiom errors (property.notFound
  on stdClass from $wpdb queries, etc.) — these require per-callsite
  docblock annotations, out of scope for this sprint.
- All 3165 existing tests pass.

https://claude.ai/code/session_013mTv5ethMq15faTc8FKta9
@rpgmem
rpgmem merged commit 6aa76db into main Apr 16, 2026
12 checks passed
@rpgmem
rpgmem deleted the claude/phpstan-level-7 branch April 16, 2026 01:28
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.

2 participants