Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't map object to abstract|interface with AsObjectMapper #241

Closed
Norbytus opened this issue Oct 22, 2024 · 2 comments · Fixed by #242
Closed

Can't map object to abstract|interface with AsObjectMapper #241

Norbytus opened this issue Oct 22, 2024 · 2 comments · Fixed by #242

Comments

@Norbytus
Copy link

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.

@Norbytus
Copy link
Author

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
    {
        /*....*/
     }
}

@priyadi
Copy link
Member

priyadi commented Oct 22, 2024

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants