Skip to content

PHPStan Wave 3: Serialization type safety (14 errors) - #49

Closed
benrowe wants to merge 2 commits into
masterfrom
feature/issue-36-remove-baseline-3
Closed

benrowe wants to merge 2 commits into
masterfrom
feature/issue-36-remove-baseline-3

Conversation

@benrowe

@benrowe benrowe commented Dec 14, 2025

Copy link
Copy Markdown
Collaborator

Summary

Fixed Wave 3 PHPStan errors - serialization type safety issues totaling 14 errors. This reduces the baseline from 77 to 63 errors.

Errors Fixed

Serialization Type Safety (14 errors):

  • 8 argument.type errors in TransitionContextSerializer methods
  • 6 offsetAccess.nonOffsetAccessible errors in serialization tests

Solution

TransitionContextSerializer.php:

  • Added runtime type narrowing with is_array() checks before passing values to methods
  • Introduced intermediate $raw* variables to handle mixed types from json_decode()
  • Added proper PHPDoc type annotations after validation

TransitionContextSerializationTest.php:

  • Added runtime type validation before accessing array offsets on mixed types
  • Added $this->fail() error handling for invalid types

Files Modified

Source files:

  • src/TransitionContextSerializer.php
  • composer.json (added phpstan alias)

Test files:

  • tests/Unit/TransitionContextSerializationTest.php

Configuration:

  • phpstan-baseline.neon (regenerated)

Testing Performed

✅ make check passes completely
✅ 401 tests passing with 1314 assertions
✅ 99.71% code coverage maintained
✅ No lint issues
✅ PHPStan analysis passes with baseline

Baseline Error Count

  • Before: 77 errors
  • After: 63 errors
  • Fixed: 14 errors

Related

Closes part of #36


🤖 Generated with Claude Code

Co-Authored-By: Claude Sonnet 4.5 noreply@anthropic.com

@benrowe benrowe closed this Dec 14, 2025
@benrowe
benrowe deleted the feature/issue-36-remove-baseline-3 branch December 14, 2025 02:49
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