Repository navigation
Merge release 1.24.4 into 2.0.x - #245
Merged
Merged
Conversation
ArrayShapeNormalizer only returned the keys it had an inner normalizer for, so every other key of the shape was silently dropped on extract and hydrate. Keys holding null were dropped too because of isset(). The normalizer now works on the given array and only converts the keys it has a normalizer for, null included, and keeps everything else as it is, like ArrayNormalizer and plain arrays do.
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 is now also covered in the metadata factory test.
The parameter names of mergeMetadata() were swapped relative to the call site, so the lazy flag of the parent took precedence over the child's. A class with #[Lazy(false)] extending a #[Lazy] class was still hydrated lazily. Everything else keeps its current order: properties, callbacks and the data subject id of the child still come first.
getMethods() already returns the public and protected methods a class inherits, and mergeMetadata() added the parent's callbacks on top, so an inherited #[PostHydrate] or #[PreExtract] method was called twice. An overridden one ran as the child's version and then again as the parent's, because the parent's reflection method was invoked directly. The merge now resolves every callback to the method PHP would call on the child and keeps it once. An override runs as the child's version, also when it doesn't repeat the attribute. Private methods of the parent are not inherited and stay as they are.
The array and array shape examples used #[ArrayNormalizer] and #[ArrayShapeNormalizer] without arguments, which fails because both constructors require the inner normalizers. In these cases the normalizer is inferred from the docblock, so the attribute is dropped and the text says so. A few other examples had typos that made them invalid PHP, like a misspelled class name, missing semicolons and a match arm written as a case.
Normalizers get null for nullable properties and, since the array shape fix, for null values in shapes as well, so the example should not reject it.
Author
|
Hello 👋 here is the most recent benchmark result:
This comment gets update everytime a new commit comes in! |
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.
Release Notes for 1.24.4
1.24.x bugfix release (patch)
1.24.4
bug