Closed Norbytus closed 3 days ago
It's then you try SourceInterface class map to certain class like
final readonly class Mapper
{
public function map(SourceInterface $source): Target
{
/*....*/
}
}
But get error on opposite direction
final readonly class Mapper
{
public function map(Source $source): TargetInterface
{
/*....*/
}
}
The bug is there, and should be fixed by the related PR. However, I got a different error message here. Try clearing your cache, and try again, my guess you will now get "Target class ... is not a valid class". If correct, then we have a cache invalidation bug that should be fixed for dev environment.
I try manually map object to interface impl, with AsObjectMapper, but always get error Trying to instantiate "TargetInterface", but it is not instantiable. You might solve this problem by adding an "InheritanceMap" to the class, so the mapper will know which concrete class to instantiate.