Skip to content

Wave 5a-G: phpstan zero — tail sweep + test fatal fix#90

Merged
detain merged 1 commit into
masterfrom
wave5a-g-tail-sweep
May 19, 2026
Merged

Wave 5a-G: phpstan zero — tail sweep + test fatal fix#90
detain merged 1 commit into
masterfrom
wave5a-g-tail-sweep

Conversation

@detain
Copy link
Copy Markdown
Owner

@detain detain commented May 19, 2026

Summary

  • Drives whole-tree phpstan level-9 errors to 0 (unbaselined). Phlex-server master phpstan reports {errors: 0, file_errors: 0} after this PR.
  • Repairs pre-existing StructuredLoggerPsrAdapterTest fatal (anonymous spy class violated LSP — diagnosed in PR Wave 5a-B: phpstan zero on Admin/Core/Logger cluster #87).
  • Cleans up 142 errors across 44 files.

Wave 5a is COMPLETE with this merge (PRs #83#88 + #89 + this). Wave 5b (delete the 3,619-line phpstan-baseline.neon and drive the absorbed errors to zero) is the next step.

Highlights

  • New helper: Phlex\Common\Util\RowMap (narrows mixed DB rows to array<string, mixed>); reused in CollectionRepository, SmartPlaylistRepository, RecordingDeduplicator, AudiobookProgressStore, MediaItem
  • Reused Phlex\LiveTv\Dto\RowAccess / RowQuery from PR Wave 5a-D: phpstan zero on LiveTv + HdHomeRunTunerDriver test fix #88 in RecordingDeduplicator
  • Rename src/Server/WebSocket/Events.php to WebSocketEvents.php (PSR-4 fix) with a thin compat shim at the old path so phpstan's excludePath entry still resolves
  • Drop 6 dead ENCODER_PREFIX / DECODER_PREFIX constants from VendorProbe classes
  • Real bugs surfaced + fixed:
    • PlaybackController called nonexistent ContainerFactory::getInstance() — converted to constructor-injected PlayToManager
    • AudiobookScanner called \getID3() as a function but the package ships a class — probe class_exists and use analyze()
    • TraktHistorySync's findMediaItemId stub returned null literal which made the rest of the loop unreachable dead code
  • Removed 5 stale phpstan-baseline.neon entries whose underlying errors were already fixed by clusters A–F

Test plan

  • phpstan whole-tree: {errors: 0, file_errors: 0}
  • phpunit StructuredLoggerPsrAdapterTest: 5/5 passing
  • phpunit tests/unit/{Auth,Collections,Playlists,Server/WebSocket,Server/Http}: green
  • phpcs PSR-12: no new errors introduced

🤖 Generated with Claude Code

… fix

Drives whole-tree phpstan level-9 errors to 0 across the 44 files
remaining after clusters A–F. Phlex-server master phpstan reports
`{errors: 0, file_errors: 0}` after this PR.

Also repairs the pre-existing `StructuredLoggerPsrAdapterTest` fatal
(anonymous spy class narrowed the parent log() signature, violating LSP).

Highlights:
- Introduce `Phlex\Common\Util\RowMap` (narrows mixed DB rows to
  array<string, mixed>) and reuse `Phlex\LiveTv\Dto\Row{Access,Query}`
  in CollectionRepository, SmartPlaylistRepository, RecordingDeduplicator,
  AudiobookProgressStore, MediaItem.
- Rename src/Server/WebSocket/Events.php to WebSocketEvents.php (PSR-4);
  leave a thin compat-shim at the old path so phpstan's excludePath entry
  still resolves until Wave 5b refreshes the config.
- Surface several pre-existing latent bugs (see commit body):
  - PlaybackController called ContainerFactory::getInstance() which does
    not exist; convert to constructor-injected PlayToManager.
  - AudiobookScanner called \getID3() as a function; package ships a
    class. Probe class_exists('getID3', false) and use ->analyze().
  - TraktHistorySync's findMediaItemId stub returned `null` literal,
    which made parseWatchedAt / extractDurationTicks unreachable dead
    code. Stub now returns ?string and reads an optional
    `_resolved_media_item_id` hint so the surrounding loop is alive
    pending the real TMDB/TVDB/IMDB lookup.
- Remove dead `ENCODER_PREFIX` / `DECODER_PREFIX` constants from 6
  VendorProbe classes.
- Narrow `Request::input()` / `$request->body` / `$params` mixed values
  in 8 controllers (Stats, Trakt OAuth, Webhook admin, Chromecast,
  Roku, DLNA renderer, Dashboard).
- Remove 5 stale `phpstan-baseline.neon` entries whose underlying
  errors were already fixed by clusters A–F (LiveTvManager x3,
  PlaybackController::$logger property.onlyWritten, SyncPlayManager
  Monolog Level argument.type).

Wave 5a is COMPLETE with this merge (PRs #83#88 + #89 + this). Wave 5b
(delete the 3,619-line `phpstan-baseline.neon` and drive the absorbed
errors to zero) is the next step.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@chatgpt-codex-connector
Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@detain detain merged commit 15c544a into master May 19, 2026
3 of 9 checks passed
@detain detain deleted the wave5a-g-tail-sweep branch May 19, 2026 21:37
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