Skip to content

Merge release 2.1.1 into 2.2.x - #247

Merged
DanielBadura merged 27 commits into
2.2.xfrom
2.1.x-merge-up-into-2.2.x_FG8rfleA
Nov 7, 2026
Merged

DanielBadura merged 27 commits into
2.2.xfrom
2.1.x-merge-up-into-2.2.x_FG8rfleA

Conversation

@github-actions

@github-actions github-actions Bot commented Nov 7, 2026

Copy link
Copy Markdown

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.
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
@github-actions

github-actions Bot commented Nov 7, 2026

Copy link
Copy Markdown
Author

Hello 👋

Here are the most recent benchmark results, compared against 2.2.x. Time is the mode over the iterations in the its column, with the relative standard deviation in brackets.

StackHydrator

subject revs its memory base current diff
benchHydrate1Object 1000 5 1.856mb -21.21% 2.453μs (±0.52%) 2.451μs (±1.45%) -0.08%
benchExtract1Object 1000 5 1.856mb -21.21% 2.807μs (±1.22%) 2.728μs (±1.13%) -2.82%
benchHydrate1000Objects 3 5 1.856mb 0.00% 2.429ms (±0.84%) 2.437ms (±1.66%) +0.33%
benchExtract1000Objects 3 5 1.856mb 0.00% 2.280ms (±1.65%) 2.286ms (±0.33%) +0.25%

StackHydratorWithCryptography

subject revs its memory base current diff
benchHydrate1Object 1000 5 1.856mb 0.00% 3.681μs (±0.88%) 3.670μs (±0.93%) -0.29%
benchExtract1Object 1000 5 1.856mb 0.00% 8.159μs (±1.00%) 8.153μs (±1.22%) -0.08%
benchHydrate1000Objects 3 5 1.856mb 0.00% 3.621ms (±1.59%) 3.584ms (±0.39%) -1.04%
benchExtract1000Objects 3 5 1.856mb 0.00% 7.637ms (±0.48%) 7.572ms (±1.04%) -0.84%

StackHydratorWithLazy

subject revs its memory base current diff
benchHydrate1Object 1000 5 1.856mb 0.00% 0.409μs (±2.67%) 0.425μs (±2.10%) +3.89%
benchHydrate1ObjectTriggerInit 1000 5 1.856mb 0.00% 2.989μs (±0.72%) 2.966μs (±1.10%) -0.78%
benchHydrate1000Objects 3 5 1.856mb 0.00% 403.194μs (±2.57%) 400.100μs (±1.06%) -0.77%
benchHydrate1000ObjectsTriggerInit 3 5 1.856mb 0.00% 3.015ms (±0.97%) 2.980ms (±0.49%) -1.18%

This comment gets updated every time a new commit comes in.

@DanielBadura
DanielBadura merged commit b045a32 into 2.2.x Nov 7, 2026
33 of 34 checks passed
@DanielBadura
DanielBadura deleted the 2.1.x-merge-up-into-2.2.x_FG8rfleA branch November 7, 2026 18:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants