WsdlToPhp / PackageGenerator

Generates a PHP SDK based on a WSDL, simple and powerful, WSDL to PHP
https://providr.io
MIT License
426 stars 73 forks source link

Xsd namespaces are not respected in generation #207

Closed ivoba closed 4 years ago

ivoba commented 4 years ago

It seems xsd namespaced imports are not respected for type generation.

I have two types with same name which are imported in different namespace but the PHP struct class is only one Type.

Type 1:

<xs:complexType name="TravellerType">
<xs:complexContent>
<xs:extension base="NonCyrillicPersonType">
...
<xs:complexType name="NonCyrillicPersonType">
<xs:element name="Contacts" type="types:NonCyrillicContactListType" minOccurs="0">

Type 2:

<xs:complexType name="TravellerType">
...
  <xs:element name="Contacts" type="t:ContactsType" minOccurs="0"/>

That leads to problem because one type extends another type which has the same element but with a different type. In PHP class this triggers an error when using reflection, f.e for AutoMappers. On class TravellerType extends NonCyrillicPersonType :

Declaration of App\Sdk\StructType\TravellerType::setContacts(?App\Sdk\StructType\ContactsType $contacts = NULL) should be compatible with App\Sdk\StructType\NonCyrillicPersonType::setContacts(?App\Sdk\StructType\NonCyrillicContactListType $contacts = NULL) /app/src/Sdk/StructType/TravellerType.php

So this mixes the setContacts from Type2 on the extended type of Type1.

mikaelcom commented 4 years ago

I currently don't have a solution for this issue as PHP won't neither be able to differentiate an object from one namespace from the other one, I think...

So either you have the possibility to rename the two elements or you won't have the possibility generated two distincts classes.

ivoba commented 4 years ago

I guess its the same problem as described here: https://github.com/phpro/soap-client/blob/master/docs/known-issues/ext-soap.md#duplicate-typenames

Luckily i was able to switch to REST and XSDs to circumvent this. I guess we can close the issue.

mikaelcom commented 4 years ago

Ok, thanks for the info :wink: