Repository navigation
Merge release 2.1.1 into 2.2.x - #247
Merged
Merged
Conversation
Fix the link to the 2.0 upgrade guide
The docs scripts parse the pages with CommonMark, which rendered the frontmatter as a thematic break and a heading. They use the FrontMatterExtension now, the same way as the scripts of the event-sourcing repository.
Keep the frontmatter when formatting the docs
getNormalizerOnClass always built the class type with Type::object(), so the guesser never saw a BackedEnumType for an enum class and never offered the EnumNormalizer. Extracting a backed enum directly gave its name and value, and hydrating it failed. An EnumNormalizer attribute without an explicit enum, on the enum or on an interface it implements, failed with a missing type for the same reason. The type is now built the way the type resolver builds it for a property of that class. An enum property with an explicit ObjectNormalizer also needs #239 to be hydrated again.
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.
Keep keys without a normalizer in array shapes
Use an enum type when looking up the class normalizer of an enum
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.
…Zsb44N Merge release 1.24.4 into 2.0.x
The class normalizer lookup walks interfaces and parent classes, so a concrete class picked up a map declared on its interface or abstract parent as its own normalizer. The map calls extract() and hydrate() on that same class again, which made those classes impossible to extract or hydrate. Like the ObjectNormalizer, the map is now ignored on class level and only applies to properties.
The parameter fix itself came with the 1.24.4 merge-up. These tests pin it for 2.x, where it also decides the class normalizer: a class extending an abstract class that implements an interface with a class normalizer gets the normalizer bound to itself and can be hydrated.
The factory never sets extras, enrichers only run on the final metadata, so both sides of the merge were always empty.
Don't use the ObjectMapNormalizer as a class normalizer
Extracting an object applies its class normalizer, so the result can be a scalar, but denormalize rejected everything that was not an array. Such a property could be written but never read back. Now the hydrator decides: it uses the class normalizer or throws ArrayDataRequired if there is none.
…lizer Pass non-array values from ObjectNormalizer to the hydrator
Author
|
Hello 👋 Here are the most recent benchmark results, compared against StackHydrator
StackHydratorWithCryptography
StackHydratorWithLazy
This comment gets updated every time 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 2.1.1
2.1.x bugfix release (patch)
2.1.1
bug