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

Option to prefix enums and structs by operation name #247

Open
rauanmayemir opened this issue Apr 7, 2021 · 2 comments
Open

Option to prefix enums and structs by operation name #247

rauanmayemir opened this issue Apr 7, 2021 · 2 comments
Assignees

Comments

@rauanmayemir
Copy link

Is your feature request related to a problem? Please describe.

It's both a bug and a feature request to resolve it.

WSDL operations can use same element names with different types. It's a normal practice because operations can use different types. But in WsdlToPhp structs are created by name and elements with name clashes are not handled in any way. If there's an already existing struct, WsdlToPhp thinks it's already been created.

If I have two WSDL operations with same name, one will work incorrectly.

Describe the solution you'd like

A simple way to resolve this would be allowing to prefix structs and enums with an operation name (similar to what could be done for services with gather method).

This could lead to a lot of meaningless duplication, so I think WsdlToPhp could be smarter in dealing with duplication by also checking the type of the element, not just name. Then, if it's a different element with same name, it could prefix or suffix it with the operation name to avoid name clashes.

Describe alternatives you've considered

More correct way would be creating elements in sub-namespaces like so:

VendorName\StructType\CreateObjectRequest
VendorName\StructType\UpdateObjectRequest
VendorName\StructType\CreateObjectRequest\Payload //  wraps ObjectDataForCreate
VendorName\StructType\UpdateObjectRequest\Payload // wraps ObjectDataForUpdate
VendorName\StructType\ObjectDataForCreate
VendorName\StructType\ObjectDataForUpdate
@mikaelcom
Copy link
Member

I think it is similar to the issue #214.

Having two structs named identically but having a different signature is complex to handle. The native SoapClient class allows to map PHP class to SOAP structs and only one PHP class can be mapped to a Struct name, classmap option. So differentiating classes based on SOAP namespace would break the mapping from SOAP response to PHP object for the structs that are duplicated by the name.

Is it possible that the "two WSDL operations with same name" are declared for different ports (which would mean their goal is the same)? Or is there goal different (which would be confusing)?

Namespacing classes based on their usage would lead to lots of generation changes potentially, meaning the PHP namespaces and class content.

Let me know if I well understood your feedback and if my thought are not fully true. Having the WSDL could be helping.

@rauanmayemir
Copy link
Author

I don't think they're in different ports. Here's an example wsdl.

The part that has name clashes (at least one that I discovered yet) is in UploadAwpRequest/awpInfoList/awpInfo (type is "ns1:AwpUploadInfo") and
AwpQueryUpdatesResponse/awpInfoList/awpInfo (type is "ns1:AwpInfo").

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

No branches or pull requests

2 participants