fix(metadata): drop unreachable array guards on serializer attributes - #8460
Merged
soyuka merged 1 commit intoAug 16, 2026
Merged
Conversation
getEffectiveSerializerAttributes() always returns array|null, so the !is_array() branches could never run. Unlike serializer groups, Symfony's AbstractNormalizer does not coerce a scalar "attributes" context, so there is no string form to normalise here.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
One of three PRs finishing the 4.3 CI unblock started in #8458. Pure dead-code removal, no behaviour change.
PHPStan (PHP 8.5) fails on 4.3 with:
getEffectiveSerializerAttributes()(:239-278) is declared@return (array|null)[]and every return path yieldsarray|null, so the!\is_array()branches could never execute. Introduced by copy-paste in64b46b2d0(#7629), where attributes support was cloned from the groups block above.Why the sibling guards are left alone
The structurally identical guards for
$normalizationGroups/$denormalizationGroupsa few lines up do not error, and that asymmetry is correct rather than an oversight:getEffectiveSerializerGroups()returns(string[]|string|null)[]— thestringmember keeps!is_array()reachable.AbstractNormalizer::getGroups()does\is_scalar($groups) ? (array) $groups : $groups, explicitly supporting a scalargroups.AbstractNormalizer::isAllowedAttribute()has no equivalent coercion forATTRIBUTES; a non-array simply falls through toreturn true.So
attributesis array-only by Symfony's own contract. Coercing a scalar here would make this factory diverge from the serializer that consumes the value.