Skip to content

Wave 5a-B: phpstan zero on Admin/Core/Logger cluster#87

Merged
detain merged 1 commit into
masterfrom
wave5a-b-admin-core-logger
May 19, 2026
Merged

Wave 5a-B: phpstan zero on Admin/Core/Logger cluster#87
detain merged 1 commit into
masterfrom
wave5a-b-admin-core-logger

Conversation

@detain
Copy link
Copy Markdown
Owner

@detain detain commented May 19, 2026

Summary

  • Drives phpstan level-9 errors to 0 in src/Admin/BackupManager.php, src/Server/Core/Application.php, src/Common/Logger/StructuredLogger.php
  • Net error reduction: ~94 / 518 (tree total: 518 → 424)
  • Fixes the StructuredLogger drift introduced during Wave 4's namespace rewrite (PR post-O.7 wave 4 (K.1): consume phlex-shared arr clients #80)
  • Introduces typed DTOs under src/Admin/Dto/ (BackupConfig, S3Config, DbConnectionConfig) with smoke tests in tests/unit/Admin/Dto/BackupConfigTest.php
  • Fixes several real bugs uncovered by phpstan: undefined $intervalDays in backup-timer closure, the convoluted key()/current() middleware iteration, Workerman\Worker::VERSION resolving inside the wrong namespace, missing AuditLogger in fallback AuthManager ctor, and the newsletter timer constructing MediaScanner/FolderWatcher with wrong arg counts/types.

Test plan

  • phpstan: 0 errors in scope files
  • phpstan whole-tree: 518 → 424 (no new errors outside scope)
  • phpunit Admin + Common/Logger unit tests: 57 passing, 1 skipped
  • phpcs PSR-12: clean (only pre-existing line-length warnings)
  • php -l: no syntax errors
  • StructuredLoggerPsrAdapterTest fatal is pre-existing on master (confirmed via stash/restore) — left for Cluster G per HANDOFF_WAVE5_PLUS.md
  • ApplicationTest TypeError is pre-existing on master (legacy ctor signature) — not introduced here

Part of Wave 5a in HANDOFF_WAVE5_PLUS.md.

🤖 Generated with Claude Code

Drives phpstan level-9 errors to 0 across:
- src/Admin/BackupManager.php
- src/Server/Core/Application.php
- src/Common/Logger/StructuredLogger.php (Wave 4 namespace-rewrite fallout)

Net error reduction: ~94 of 518. Part of Wave 5a per HANDOFF_WAVE5_PLUS.md.

Introduces typed value-object DTOs under src/Admin/Dto/ to replace the
"array<string, mixed> $config" shape that BackupManager used internally:
- BackupConfig (with hasCredentials() helper)
- S3Config
- DbConnectionConfig

Also fixes real bugs uncovered along the way:
- registerBackupTimer() closure was capturing $intervalSeconds (unused)
  and referencing undefined $intervalDays — swapped use clause.
- run() middleware iteration used current()/key() with a possibly-false
  key as array index — replaced with array_reverse + foreach.
- Workerman\Worker::VERSION was resolving relative to current namespace
  (Phlex\Server\Core\Workerman\Worker) — anchored with leading backslash.
- AuthManager fallback construction missed the required AuditLogger
  parameter — wired a real AuditLogger in the no-container code path.
- Newsletter timer was constructing MediaScanner with 1 arg (needs 2-5)
  and FolderWatcher with a Connection (it takes no required args) —
  fixed both to use real ItemRepository and no-arg FolderWatcher.

StructuredLogger's Monolog 3 processors now properly accept and return
LogRecord (the Wave 4 namespace rewrite left the Monolog-2-shaped array
processors that no longer satisfied pushProcessor's callable contract).
Dead withContext() method that referenced a nonexistent Monolog 3
method was removed.

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 55e629a into master May 19, 2026
2 of 9 checks passed
@detain detain deleted the wave5a-b-admin-core-logger branch May 19, 2026 04:53
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