Skip to content

add union object normalizer#40

Merged
DavidBadura merged 1 commit into
1.16.xfrom
union-object-normalizer
Feb 17, 2026
Merged

add union object normalizer#40
DavidBadura merged 1 commit into
1.16.xfrom
union-object-normalizer

Conversation

@DavidBadura

@DavidBadura DavidBadura commented Apr 5, 2024

Copy link
Copy Markdown
Member
use Patchlevel\Hydrator\Normalizer\UnionObjectNormalizer;

#[UnionObjectNormalizer([
  ContentBlock::class => 'content',
  CodeBlock::class => 'code'
])]
interface Block
{
}

@DavidBadura
DavidBadura requested a review from DanielBadura April 5, 2024 15:48
@DavidBadura DavidBadura added the enhancement New feature or request label Apr 5, 2024
@DavidBadura DavidBadura added this to the 1.3.0 milestone Apr 5, 2024
@github-actions

github-actions Bot commented Apr 5, 2024

Copy link
Copy Markdown

Hello 👋

here is the most recent benchmark result:

HydratorWithLazyBench
=====================

+------------------------------------------+--------------------+--------------------+-----------------+------------+
|                                          | time (kde mode)                         | memory                       |
+------------------------------------------+--------------------+--------------------+-----------------+------------+
| subject                                  | Tag: <current>     | Tag: base          | Tag: <current>  | Tag: base  |
+------------------------------------------+--------------------+--------------------+-----------------+------------+
| benchHydrate1Object ()                   | 0.800μs (±0.00%)   | 0.800μs (±0.00%)   | 2.770mb         | 3.253mb    |
| benchHydrate1ObjectTriggerInit ()        | 9.200μs (±0.00%)   | 6.600μs (±0.00%)   | 2.770mb         | 3.253mb    |
| benchHydrate1000Objects ()               | 456.333μs (±0.00%) | 440.667μs (±0.00%) | 2.808mb         | 3.272mb    |
| benchHydrate1000ObjectsTriggerInit ()    | 3.291ms (±0.00%)   | 3.292ms (±0.00%)   | 2.806mb         | 2.806mb    |
| benchHydrate1000000Objects ()            | 309.996ms (±0.00%) | 317.499ms (±0.00%) | 2.808mb         | 2.808mb    |
| benchHydrate1000000ObjectsTriggerInit () | 2.104s (±0.00%)    | 2.076s (±0.00%)    | 2.806mb         | 2.806mb    |
+------------------------------------------+--------------------+--------------------+-----------------+------------+

HydratorBench
=============

+-------------------------------+------------------+------------------+-----------------+------------+
|                               | time (kde mode)                     | memory                       |
+-------------------------------+------------------+------------------+-----------------+------------+
| subject                       | Tag: <current>   | Tag: base        | Tag: <current>  | Tag: base  |
+-------------------------------+------------------+------------------+-----------------+------------+
| benchHydrate1Object ()        | 3.800μs (±0.00%) | 3.200μs (±0.00%) | 2.770mb         | 2.770mb    |
| benchExtract1Object ()        | 3.600μs (±0.00%) | 4.000μs (±0.00%) | 2.770mb         | 2.770mb    |
| benchHydrate1000Objects ()    | 2.254ms (±0.00%) | 2.274ms (±0.00%) | 2.855mb         | 2.855mb    |
| benchExtract1000Objects ()    | 2.304ms (±0.00%) | 2.321ms (±0.00%) | 2.818mb         | 2.818mb    |
| benchHydrate1000000Objects () | 1.203s (±0.00%)  | 1.212s (±0.00%)  | 2.855mb         | 2.855mb    |
| benchExtract1000000Objects () | 1.357s (±0.00%)  | 1.394s (±0.00%)  | 2.818mb         | 2.818mb    |
+-------------------------------+------------------+------------------+-----------------+------------+

HydratorWithCryptographyBench
=============================

+-------------------------------+-------------------+-------------------+-----------------+------------+
|                               | time (kde mode)                       | memory                       |
+-------------------------------+-------------------+-------------------+-----------------+------------+
| subject                       | Tag: <current>    | Tag: base         | Tag: <current>  | Tag: base  |
+-------------------------------+-------------------+-------------------+-----------------+------------+
| benchHydrate1Object ()        | 7.400μs (±0.00%)  | 7.800μs (±0.00%)  | 2.881mb         | 2.881mb    |
| benchExtract1Object ()        | 10.200μs (±0.00%) | 10.600μs (±0.00%) | 2.881mb         | 2.881mb    |
| benchHydrate1000Objects ()    | 4.700ms (±0.00%)  | 4.699ms (±0.00%)  | 3.011mb         | 3.011mb    |
| benchExtract1000Objects ()    | 6.053ms (±0.00%)  | 8.346ms (±0.00%)  | 2.921mb         | 2.921mb    |
| benchHydrate1000000Objects () | 2.450s (±0.00%)   | 2.437s (±0.00%)   | 3.011mb         | 3.011mb    |
| benchExtract1000000Objects () | 4.225s (±0.00%)   | 4.236s (±0.00%)   | 2.921mb         | 2.921mb    |
+-------------------------------+-------------------+-------------------+-----------------+------------+

This comment gets update everytime a new commit comes in!

@DanielBadura DanielBadura left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Feature itself LGTM.

Just thinking about instead of passing an array to the UnionObjectNormalizer leveraging the #[NormalizedName] Attribute or something like that. But also that is kina weird, since it does not really bring any value itself.

Comment thread src/Normalizer/UnionObjectNormalizer.php
@DavidBadura DavidBadura removed this from the 1.3.0 milestone Apr 11, 2024
@DavidBadura

Copy link
Copy Markdown
Member Author

It's possible, but I don't have a use case for it myself. Therefore, I'm closing this pull request.

@DavidBadura
DavidBadura deleted the union-object-normalizer branch February 14, 2026 09:07
@DavidBadura
DavidBadura restored the union-object-normalizer branch February 17, 2026 10:53
@DavidBadura DavidBadura reopened this Feb 17, 2026
@DavidBadura
DavidBadura force-pushed the union-object-normalizer branch from d2a1e3d to 3c30af3 Compare February 17, 2026 11:01
@DavidBadura
DavidBadura changed the base branch from 1.3.x to 1.16.x February 17, 2026 11:02
@DavidBadura
DavidBadura force-pushed the union-object-normalizer branch from 3c30af3 to 96037b0 Compare February 17, 2026 11:10
@DavidBadura
DavidBadura force-pushed the union-object-normalizer branch from 96037b0 to 8d95bb0 Compare February 17, 2026 11:14
@DavidBadura DavidBadura added this to the 1.16.0 milestone Feb 17, 2026
@DavidBadura
DavidBadura merged commit 9a356a3 into 1.16.x Feb 17, 2026
15 of 16 checks passed
@DavidBadura
DavidBadura deleted the union-object-normalizer branch February 17, 2026 11:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants