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

Cannot generate StructArray #212

Closed rauanmayemir closed 3 years ago

rauanmayemir commented 4 years ago

I've set ->setStructArrayClass(BaseStructArray::class) option in GeneratorOptions, but I don't see any of my structs to be extended from it (when it's clearly a sort of array wrapper thing).

How can I make a repro case for it? I couldn't find any unit tests for struct_array.

mikaelcom commented 4 years ago

This option is used in the getExtends method depending if the struct is actually an Array Struct or not.

The StructArrayTest contains the tests about the usage of the option (but I must admit without another class that the default one) but the GeneratorOptionsTest ensures the option is well set.

rauanmayemir commented 4 years ago

Does StructArray handle cases like:

<Products>
  <Product>...</Product>
  <Product>...</Product>
</Products>

where Products would extend BaseStructArray, or it's for some other use cases?

mikaelcom commented 4 years ago

It depends on several conditions visible in the isArray method that depends from the XSD declaration.

Can you paste it?

rauanmayemir commented 4 years ago

Here's an XSD example:

<xs:element name="products">
  <xs:complexType>
    <xs:sequence>
      <xs:element name="product" type="tns:Product" minOccurs="1" maxOccurs="unbounded">
      </xs:element>
    </xs:sequence>
  </xs:complexType>
</xs:element>
<xs:complexType name="Product">
  <xs:sequence>
    <xs:element name="name" type="xs:string" minOccurs="0">
    </xs:element>
    <xs:element name="description" type="xs:string" minOccurs="0">
    </xs:element>
    <xs:element name="quantity" minOccurs="0">
      <xs:simpleType>
        <xs:restriction base="xs:decimal">
          <xs:fractionDigits value="6"/>
          <xs:totalDigits value="18"/>
        </xs:restriction>
      </xs:simpleType>
    </xs:element>
  </xs:sequence>
</xs:complexType>
rauanmayemir commented 4 years ago

Products struct will have a static validateProductForArrayConstraintsFromSetProduct method, but I wish there was also a better way to understand that struct consumes an array.

mikaelcom commented 4 years ago

It may depend from the element/complexType that uses the products element.

I'm not sure to understand what's bothering/blocking you... If you can send me the complete WSDL and what you expect, I'll possibly get a better picture of your need.

rauanmayemir commented 4 years ago

There's no WSDL, cause I'm doing this out of XSD only.

What was bothering me is that I was traversing XML manually and trying to hydrate the struct. I couldn't know if the struct accepted arrays, but I solved it by checking if there was an addToProperty method (that would mean 'property' is array). I stopped pursuing this direction due to other issues.

mikaelcom commented 4 years ago

SOAP and its beauty :sweat_smile: