WsdlToPhp / PackageGenerator

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

choice tag is not fully handled properly #257

Closed mikaelcom closed 3 years ago

mikaelcom commented 3 years ago

Describe the bug If a choice tag is present with the attribute maxOccurs superior to 1, it should mark the child elements as array and not single item.

To Reproduce Generate the package when having this choice tag:

<xs:complexType name='LigneFTTHType'>
 <xs:sequence>
  <xs:choice minOccurs='1' maxOccurs='2'>
    <xs:element maxOccurs='1' minOccurs='0' name='prise' nillable='false' type='ns1:PriseType'/>
    <xs:element maxOccurs='1' minOccurs='0' name='local' nillable='false' type='ns1:LocalType'/>
   </xs:choice>
  </xs:sequence>
</xs:complexType>

Expected behavior

/**
 * The prise
 * Meta information extracted from the WSDL
 * - choice: prise | local
 * - choiceMaxOccurs: 2
 * - choiceMinOccurs: 1
 * - maxOccurs: 1
 * - minOccurs: 0
 * - nillable: false
 * @var \ProviderService\Provider\Free\FTTH\StructType\PriseType[]
 */
 protected array $prise = [];
/**
 * The local
 * Meta information extracted from the WSDL
 * - choice: prise | local
 * - choiceMaxOccurs: 2
 * - choiceMinOccurs: 1
 * - maxOccurs: 1
 * - minOccurs: 0
 * - nillable: false
 * @var \ProviderService\Provider\Free\FTTH\StructType\LocalType[]
 */
 protected array $local = [];
mikaelcom commented 3 years ago

Only direct children properties should be marked as array. For instance, if the children are contained by a sequence tag, then the children should not be marked as array-typed properties