EventSaucePHP / ObjectHydrator

Object Hydration library to create Command and Query objects.
MIT License
316 stars 23 forks source link

Support MapperSettings on interfaces #45

Closed shadowhand closed 1 year ago

shadowhand commented 1 year ago

I have a set of classes that implement an interface that should never have their public methods serialized. I would like to place a MapperSettings on this interface to reduce repetition (>150 implementations in my case).

Right now DefinitionProvider::resolveObjectSettings() only supports reading the settings from the current class. This would need to be modified to search implemented interfaces when the class itself does not have MapperSettings.

_Edit: Previously this description mentioned using ReflectionAttribute::IS_INSTANCEOF to achieve this goal, but that was a misunderstanding of how the flag worked._

frankdejonge commented 1 year ago

As far as I know, the IS_INSTANCEOF filter uses an instanceof check to filter the attributes, so it doesn't cascade up the interface/class-hierarchy tree.

shadowhand commented 1 year ago

@frankdejonge you're correct. I have made a PR that implements the behavior that I want.