-
-
Notifications
You must be signed in to change notification settings - Fork 75
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
Support mapping from json encoded mapping result #136
Conversation
Hi @mtouellette, thank you for the contribution. Although I understand your needs, this pull request cannot be merged as it is: the library wont support custom oriented implementations of Still, I think you can manage to make it working on your side, can you try this in your application: try {
$result = (new \CuyZ\Valinor\MapperBuilder())
->infer(DateTimeInterface::class, fn() => SomeJsonSerializableDateTime::class)
->mapper()
->map(SomeClass::class, [/* … */]);
} catch (MappingError $error) {
// …
} But your proposition reminded me that the try {
$result = (new \CuyZ\Valinor\MapperBuilder())
->infer(DateTime::class, fn() => SomeClassThatInheritsDateTime::class)
->mapper()
->map(SomeClass::class, [/* … */]);
} catch (MappingError $error) {
// …
} |
HI @romm, I figured this pull request was a bit of a reach and ended up getting around the issue for now with a source modifier which isn't great but seems to do the trick. Thanks for reviewing this and for the excellent library. |
I'm glad you could solve your issue, what about the solution I posted above? Could it help? |
It looks like it might, though I haven't tried yet. I'm dealing with a lot of auto generated code from an OpenApi specification and the output of the data transfer objects uses DateTime rather than DateTimeInterface. Will infer work with concrete classes as well as interfaces? |
Ok, thanks for the info. That's what I wrote above, unfortunately inferring wont work with classes inheritance for the moment; this is clearly a missing feature that I will be adding to the library at some point: check for next releases! |
Ah, I see. I'll certainly keep an eye out for updates. Thanks again! |
useful in api integration tests