You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
SoapClient can't convert BackedEnum to scalar value #15711
I think the main question here would be if we consider SOAPClient to be a serialization context. serialize(), json_encode(), etc. are, and so use the backing value. Would SOAPClient fall into that category? If so, pulling the backing value makes sense. If not, it doesn't.
However, I'm not sure where to draw the line about what we support. https://pecl.php.net/package/xmlrpc is likely of no concern any longer, although XMLRPC can be regarded as precursor to SOAP. But there are likely more relevant packages, e.g. https://pecl.php.net/package/yaml. Well, not bundled extension probably need to decide for themselves, but what about XMLWriter and FFI (not really serialization, but somewhat related), for instance?
What's the definition of "serialization context"? I guess it depends on that.
In any case, this error comes from zval_get_string_func called from to_xml_string when trying to convert the field to a string. So to me, it is casting, not serialization, and therefore, there is nothing to do here.
@nielsdos Works great!
While testing I thought about integer enums, I don't have them in my use case, but I think they should be supported too.
I did a test with definition like this
Activity
cmb69 commentedon Sep 2, 2024
Somewhat related to #15650. Quoting from there:
So this is not a bug, but might be a legit feature request.
cmb69 commentedon Sep 6, 2024
cc @Crell and @iluuu1994
Crell commentedon Sep 6, 2024
I think the main question here would be if we consider SOAPClient to be a serialization context. serialize(), json_encode(), etc. are, and so use the backing value. Would SOAPClient fall into that category? If so, pulling the backing value makes sense. If not, it doesn't.
cmb69 commentedon Sep 6, 2024
I think, we do. @nielsdos can possibly clarify.
However, I'm not sure where to draw the line about what we support. https://pecl.php.net/package/xmlrpc is likely of no concern any longer, although XMLRPC can be regarded as precursor to SOAP. But there are likely more relevant packages, e.g. https://pecl.php.net/package/yaml. Well, not bundled extension probably need to decide for themselves, but what about XMLWriter and FFI (not really serialization, but somewhat related), for instance?
ndossche commentedon Sep 6, 2024
What's the definition of "serialization context"? I guess it depends on that.
In any case, this error comes from zval_get_string_func called from to_xml_string when trying to convert the field to a string. So to me, it is casting, not serialization, and therefore, there is nothing to do here.
MrMeshok commentedon Sep 8, 2024
Let me show you how I got to this issue.
I have WSDL with this definition of enum
So I created Enum and DTO which I will pass to SoapClient
For me it's seems reasonable, to expect for it to just work.
If instead of SOAP it was some JSON RPC API I would just json_encode my DTO and it will work how I expected it.
{ "AuthMethod": "SessionToken", "SessionToken": "123345" }6 remaining items
ndossche commentedon Sep 8, 2024
I've opened #15803 to fix this. @MrMeshok If possible please test this.
MrMeshok commentedon Sep 9, 2024
@nielsdos Works great!
While testing I thought about integer enums, I don't have them in my use case, but I think they should be supported too.
I did a test with definition like this
Which will result in error: Object of class TestIntegerEnum could not be converted to int
ndossche commentedon Sep 9, 2024
Thanks for testing. Supporting this for ints makes sense, I'll give it a shot.
ndossche commentedon Sep 9, 2024
@MrMeshok I updated the PR with support for int backed enums being serialized with xsd:integer (and alike) types.
Implement phpGH-15711: Allow SoapClient to use the backing value duri…
Implement phpGH-15711: Allow SoapClient to use the backing value duri…
Fix GH-15711: SoapClient can't convert BackedEnum to scalar value
Merge branch 'PHP-8.3'