-
-
Notifications
You must be signed in to change notification settings - Fork 21
Static converters #527
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
Static converters #527
Conversation
Hi! #523 (comment) I’ll try to submit two bug reports by the end of the day that blocked us from upgrading from version 1.256 and above. |
* @return stdClass[] | ||
*/ | ||
#[Converter] | ||
public static function convert(array $data): iterable |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is the use case for allowing converter to work on arrays, instead of specific singular types?
Converter would be called multiple times for given type, meaning string => stdClass
, will cover string[]
=> stdClass[]
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's a copy/paste of an existing test case, I'm not changing the behavior here.
But as you mention, I would have liked the converters to only be able to convert from array to object or from object to array (only normalization and denormalization), that would have allowed me to do converter resolution at compile time in #526
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would have liked the converters to only be able to convert from array to object or from object to array
@jlabedo I don't think we can do that. Things like Enums converted to scalars in headers would stop working.
But you can point me to the place where it will be needed and we think of the solution there
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's a copy/paste of an existing test case, I'm not changing the behavior here.
Oki then, I would expect this one to fail :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jlabedo I don't think we can do that. Things like Enums converted to scalars in headers would stop working.
You are right, I meant from scalar to object and from object to scalar. And by scalar I mean int,float,bool,string,arrayOfScalars.
But you can point me to the place where it will be needed and we think of the solution there
Nowhere in Ecotone, but it could be a BC if people have used this feature.
packages/Ecotone/tests/Messaging/Unit/Conversion/ReferenceServiceConverterBuilderTest.php
Show resolved
Hide resolved
@jlabedo can you update the docs? You can do it directly in the documention repo, as each merge republishes the doc |
Why is this change proposed?
Allow defining static function for converters, eg. :
Description of changes
For projecting benchmark: added static converters and disabled JMS that a substantial impact on this benchmark
Pull Request Contribution Terms