Repository navigation
Infer normalizers for nullable collection items - #242
Closed
DavidBadura wants to merge 4 commits into
Closed
DavidBadura wants to merge 4 commits into
DavidBadura wants to merge 4 commits into
Conversation
The collection branch unwrapped the nullable item type from the collection itself instead of from the item type, so collections like list<?Skill> got no normalizer at all and their items were passed through as raw objects.
An explicit ArrayShapeNormalizer map can contain keys that the property's docblock shape doesn't know. handleType read those keys anyway and raised undefined key warnings. Such fields are now left alone, like the whole map is when the property type isn't an array shape.
The collection and array shape branches unwrapped nullable item types and looked for a class normalizer before recursing, although inferNormalizerByType does both on its own. Dropping the duplicate removes the place where the nullable item bug came from.
The shape branch of inferNormalizerByType was only reached through the hydrator tests, which do not cover the metadata factory.
|
Hello 👋 Here are the most recent benchmark results, compared against StackHydrator
StackHydratorWithCryptography
StackHydratorWithLazy
This comment gets updated every time a new commit comes in. |
DanielBadura
approved these changes
Nov 6, 2026
Member
Author
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.
The collection branch of
inferNormalizerByType()unwrapped the nullable type of the collection instead of its items, solist<?Skill>,array<string, ?Status>,list<?DateTimeImmutable>and every other collection with nullable items got no normalizer and were stored raw. The second fix stopsArrayShapeNormalizer::handleType()from reading type info for an explicit map key that the docblock shape does not have, which raised warnings. The third commit is a pure simplification: the collection and shape branches no longer unwrap item types and look for a class normalizer themselves, since the recursive call does both, and that duplicate is where the first bug came from.Release note: collections with nullable items of objects, enums or dates are now normalized. Before, the raw objects went into the payload, and hydrating returned arrays or strings instead of the declared type. Enums keep the same JSON. Old payloads with dates (
{"date": ..., "timezone_type": ..., "timezone": ...}) or value objects can no longer be hydrated after the update, so stored events with such collections need an upcaster that converts them to the normalized format. Custom normalizers used for such items now also receivenull.Please merge #241 first. This change gives shapes reached through nullable items an
ArrayShapeNormalizer, and without #241 that normalizer drops the keys it has no normalizer for.