Ocramius / GeneratedHydrator

:bullettrain_side: Fast Generated Object Hydrator for PHP
MIT License
727 stars 69 forks source link

Metadata for hydrator generation? #38

Open sandermarechal opened 8 years ago

sandermarechal commented 8 years ago

@Ocramius and others, I wonder what your opinion is about metadata for hydrator generation.

For example, I'd like to see integration for hydrator strategies or nesting hydrators, but it seems to me that you'd need to have some kind of metadata about how to map the array to the object. Thinks like, for example:

I think some kind of metadata is required to support these use cases, but I don't think you'd want to replicate a large part of e.g. JMS/Serializer. The point of generated hydrators is to be very, very fast.

What would be a sane way to go about this?

Ocramius commented 8 years ago

I wonder what your opinion is about metadata for hydrator generation.

More like a DSL for how to define a hydrator (that would really be useful).

What you are asking for is a bit far fetched, tbh, but it can be done.

I have no plan on how to approach it, but the idea is to have:

pounard commented 6 years ago

By creating a simpler and specific AST for hydrators only, this would allow to get rid of the nikic/parser dependency, and remove a lot of complexity from the existing code, at the cost of having to maintain its own AST - but I think that, if the goal of this API is to generate complex hydrator trees for specific needs, it would worth it. It would also allow to do things such as a bridge to Symfony property info component (that would work both ways actually).