-
-
Notifications
You must be signed in to change notification settings - Fork 30
Description
What's wrong
When hydrating a payload back to an object, the hydrator never checks if a default caster exists for the outer most object. Typically this isn't a problem, because most of the time the class you are hydrating consists of properties that the mapper can hydrate (either through casters or just by using reflection). However this also means that you can't use a caster to call another caster (by calling $hydrator->hydrateObject(Some::Class, $somePayload)).
My use case
My current use case for calling one caster from another is that I'm trying to support array shapes, this involves providing an attribute for each key in the array that needs to be cast to a type (e.g. #[CastArrayItem('foo', Foo::class)]), as well as using this package's #[SerializeArrayItems]. For the most part this works fine, but I'm currently unable to hydrate any values that require a caster.
PS. Am happy to attempt a PR if you feel this is the right direction