Skip to content

fix: remove redundant is_array() check in Serializer#2020

Merged
DerManoMann merged 1 commit into
zircote:masterfrom
DerManoMann:fix/phpstan-serializer-is-array
Jun 12, 2026
Merged

fix: remove redundant is_array() check in Serializer#2020
DerManoMann merged 1 commit into
zircote:masterfrom
DerManoMann:fix/phpstan-serializer-is-array

Conversation

@DerManoMann

Copy link
Copy Markdown
Collaborator

Summary

  • PHPStan reported is_array() on $declaration always evaluates to true in Serializer::doDeserializeProperty()
  • Root cause: after checking is_string($declaration) with a separate if, the subsequent is_array() checks were redundant since the type union is string|array<string>
  • Restructured to use if/elseif branching so the string case is handled first and the array branches follow naturally without needing explicit is_array() guards

Test plan

  • composer analyse — 0 errors
  • composer test — 1037 tests pass
  • CS Fixer clean
  • Rector clean

🤖 Generated with Claude Code

Restructure the declaration type checks in doDeserializeProperty() to
use if/elseif branching on is_string($declaration), so PHPStan can
narrow the type and the is_array() guard is no longer needed.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@DerManoMann DerManoMann merged commit 3715043 into zircote:master Jun 12, 2026
17 checks passed
@DerManoMann DerManoMann deleted the fix/phpstan-serializer-is-array branch June 12, 2026 05:03
@github-actions

Copy link
Copy Markdown
Contributor

Successfully created backport PR for 5.x:

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