Skip to content

Conversation

@DavidBadura
Copy link
Member

No description provided.

@DavidBadura DavidBadura added this to the 2.0.0 milestone Jan 6, 2026
@DavidBadura DavidBadura added BC break enhancement New feature or request labels Jan 6, 2026
@github-actions
Copy link

github-actions bot commented Jan 6, 2026

Hello 👋

here is the most recent benchmark result:

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

+-------------------------------+-------------------+-------------------+-----------------+------------+
|                               | time (kde mode)                       | memory                       |
+-------------------------------+-------------------+-------------------+-----------------+------------+
| subject                       | Tag: <current>    | Tag: base         | Tag: <current>  | Tag: base  |
+-------------------------------+-------------------+-------------------+-----------------+------------+
| benchHydrate1Object ()        | 76.200μs (±0.00%) | 76.600μs (±0.00%) | 2.758mb         | 3.174mb    |
| benchExtract1Object ()        | 9.600μs (±0.00%)  | 16.000μs (±0.00%) | 2.711mb         | 3.174mb    |
| benchHydrate1000Objects ()    | 3.939ms (±0.00%)  | 4.041ms (±0.00%)  | 2.965mb         | 3.423mb    |
| benchExtract1000Objects ()    | 5.503ms (±0.00%)  | 5.476ms (±0.00%)  | 2.937mb         | 3.396mb    |
| benchHydrate1000000Objects () | 2.183s (±0.00%)   | 2.165s (±0.00%)   | 2.965mb         | 3.423mb    |
| benchExtract1000000Objects () | 3.951s (±0.00%)   | 4.012s (±0.00%)   | 2.937mb         | 2.936mb    |
+-------------------------------+-------------------+-------------------+-----------------+------------+

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

+-------------------------------+-------------------+-------------------+-----------------+------------+
|                               | time (kde mode)                       | memory                       |
+-------------------------------+-------------------+-------------------+-----------------+------------+
| subject                       | Tag: <current>    | Tag: base         | Tag: <current>  | Tag: base  |
+-------------------------------+-------------------+-------------------+-----------------+------------+
| benchHydrate1Object ()        | 78.200μs (±0.00%) | 73.000μs (±0.00%) | 2.695mb         | 2.695mb    |
| benchExtract1Object ()        | 4.000μs (±0.00%)  | 4.000μs (±0.00%)  | 2.695mb         | 2.695mb    |
| benchHydrate1000Objects ()    | 2.623ms (±0.00%)  | 2.592ms (±0.00%)  | 2.788mb         | 2.787mb    |
| benchExtract1000Objects ()    | 2.544ms (±0.00%)  | 2.768ms (±0.00%)  | 2.727mb         | 2.695mb    |
| benchHydrate1000000Objects () | 1.503s (±0.00%)   | 1.531s (±0.00%)   | 2.788mb         | 2.787mb    |
| benchExtract1000000Objects () | 1.724s (±0.00%)   | 1.720s (±0.00%)   | 2.727mb         | 2.695mb    |
+-------------------------------+-------------------+-------------------+-----------------+------------+

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

+------------------------------------------+--------------------+--------------------+-----------------+------------+
|                                          | time (kde mode)                         | memory                       |
+------------------------------------------+--------------------+--------------------+-----------------+------------+
| subject                                  | Tag: <current>     | Tag: base          | Tag: <current>  | Tag: base  |
+------------------------------------------+--------------------+--------------------+-----------------+------------+
| benchHydrate1Object ()                   | 0.800μs (±0.00%)   | 1.000μs (±0.00%)   | 2.695mb         | 2.695mb    |
| benchHydrate1ObjectTriggerInit ()        | 119.200μs (±0.00%) | 124.200μs (±0.00%) | 2.767mb         | 2.767mb    |
| benchHydrate1000Objects ()               | 439.333μs (±0.00%) | 473.667μs (±0.00%) | 2.726mb         | 2.695mb    |
| benchHydrate1000ObjectsTriggerInit ()    | 3.336ms (±0.00%)   | 3.398ms (±0.00%)   | 2.767mb         | 2.767mb    |
| benchHydrate1000000Objects ()            | 298.378ms (±0.00%) | 346.144ms (±0.00%) | 2.726mb         | 2.695mb    |
| benchHydrate1000000ObjectsTriggerInit () | 2.260s (±0.00%)    | 2.275s (±0.00%)    | 2.767mb         | 2.767mb    |
+------------------------------------------+--------------------+--------------------+-----------------+------------+

This comment gets update everytime a new commit comes in!


interface GuesserProvider
{
/** @return iterable<Guesser|array{0: Guesser, 1?: int}> */
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
/** @return iterable<Guesser|array{0: Guesser, 1?: int}> */
/** @return iterable<array{0: Guesser, 1?: int}> */

I think reducing it to this is a better api, otherwise we have 2 version's to omit the priority as the also allow here the priority to be missing. wdyt?

Copy link
Member Author

Choose a reason for hiding this comment

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

I do not think either "type" is harmful, and I like the DX of the first one. Besides, it is practically the same principle as in Symfony.


interface MetadataEnricherProvider
{
/** @return iterable<MetadataEnricher|array{0: MetadataEnricher, 1?: int}> */
Copy link
Member

Choose a reason for hiding this comment

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

same here

use Patchlevel\Hydrator\Middleware\Middleware;
use Patchlevel\Hydrator\MiddlewareProvider;

final class CryptographyExtension implements MiddlewareProvider, MetadataEnricherProvider
Copy link
Member

@DanielBadura DanielBadura Jan 6, 2026

Choose a reason for hiding this comment

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

other idea which i have in mind is: instead of this provider use attributes to define middleware/metadataenricher?

#[Middleware(priority: 64)]
final readonly class CryptographyMiddleware implements Middleware {}

Copy link
Member Author

Choose a reason for hiding this comment

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

No, I do not want to work with attributes here. I think attributes are good if you want to enrich your own code (from your domain) with information from external sources. But not as an extension point for the library. I would always prefer interfaces for that.

Copy link
Member

Choose a reason for hiding this comment

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

I dont want to remove the interface (I missed it in the small code example) it's more about the provider / configuration of the priority

Copy link
Member Author

Choose a reason for hiding this comment

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

The extension is there to register the middleware, etc. I find it unnecessary to read the attributes from it. In my opinion, that adds no value and only complicates things.

I am also considering whether interfaces like MiddlewareProvider are overkill, and whether it would be better to simply provide an abstract class Extension that predefines methods with empty arrays. That would also make things simpler.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

BC break enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants