Repository navigation
Conversation
| { | ||
| $normalizationGroups = $resourceMetadata->getNormalizationContext()[AbstractNormalizer::GROUPS] ?? null; | ||
| $denormalizationGroups = $resourceMetadata->getDenormalizationContext()[AbstractNormalizer::GROUPS] ?? null; | ||
| $normalizationGroups = ($resourceMetadata->getNormalizationContext() ?? [])[AbstractNormalizer::GROUPS] ?? null; |
There was a problem hiding this comment.
We should probably just type somewhere that our groups should be array shaped. I think there are other places in the code were we rely on that behavior.
|
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
bf0abd3 to
d240bdd
Compare
|
Confirmed as a real bug, and I have retargeted this to For the record, the case for the fix:
Symfony's own Two small things before it can go in:
Thanks for the patch and for your patience on the delay. |
|
Shall I pick up those two points or will you? |
|
Oh this was an agentic issue, I'll take care of this :) will be released today |
DocumentationNormalizer::getPropertyMetadataFactoryContextcrashes when serialization groups are defined as a string rather than an array, or when no normalization/denormalization context is set.Symfony's serializer supports string groups.
AbstractNormalizer::getGroups()casts scalars to arrays, and the Symfony docs demonstrate the following is possible'groups' => 'public_view'.Reproducer:
#[ApiResource( normalizationContext: ['groups' => 'read'], denormalizationContext: ['groups' => 'write'], )] class DragonTreasure { ... }Requesting the Hydra documentation endpoint produces:
Warning: foreach() argument must be of type array|object, string given(string groups passed toforeach)Warning: Trying to access array offset on null(when context isnull)Fix:
getNormalizationContext()/getDenormalizationContext()with?? []to handlenullcontextsAbstractNormalizer::getGroups()behaviour