WsdlToPhp / PackageGenerator

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

Getter for a nullable-array-typed property is invalid #272

Closed mikaelcom closed 2 years ago

mikaelcom commented 2 years ago

Describe the bug Generating a class containing an nullable-array-typed property generates an invalid getter:

    /**
     * Get EditAdult value
     * @return \Stub\StructType\EditAdultElement[]
     */
    public function getEditAdult(): array
    {
        return isset($this->EditAdult) ? $this->EditAdult : null;
    }

To Reproduce Generate a package from a WSDL containing an array-typed property which is contained by a choice element:

<s:complexType name="ArrayOfChoice8">
 <s:choice minOccurs="0" maxOccurs="unbounded">
  <s:element minOccurs="1" maxOccurs="1" name="EditAdult" nillable="true" type="tns:EditAdultElement"/>
  <s:element minOccurs="1" maxOccurs="1" name="EditChild" nillable="true" type="tns:EditChildElement"/>
  <s:element minOccurs="1" maxOccurs="1" name="EditGuest" nillable="true" type="tns:EditGuestElement"/>
 </s:choice>
</s:complexType>

Expected behavior

    /**
     * Get EditAdult value
     * @return \Stub\StructType\EditAdultElement[]|null
     */
    public function getEditAdult(): ?array
    {
        return $this->EditAdult ?? null;
    }