Skip to content

Constraints generate after misread of choice block #340

@etshy

Description

@etshy

Describe the bug
The package generator (installed today so up to date) generated a maxOccurs constraint in a setter when he should have not.
Edit: I just tested, it seems the CommandLine installation is downloading the version 4.1.12. So the generation was with 4.1.12.
Just tested with 4.1.17, same error anyway.

To Reproduce
Steps to reproduce the behavior:

  • Using the following definition (simplified to the extreme)
  • Generatea package (command used : wsdltophp generate:package --urlorpath="wsdlurl" --destination="./path/to/wsdl" --namespace="Wsdl\WsdlService" --standalone=false --force --namespace-directories false)

Expected behavior
No validation of maxOccurs for this setter

Additional context
Here is an oversimplified definition

<definitions>
   <types>
      <xs:schema>
         <xs:complexType name="EquipmentItemType">
            <xs:sequence>
              <!-- Elements -->
            </xs:sequence>
         </xs:complexType>
         <xs:complexType name="VehicleType">
            <xs:sequence>
               <xs:choice>
                  <xs:element maxOccurs="unbounded" minOccurs="0" name="Equipment" type="tns:EquipmentItemType"/>
                  <!-- Others possibles elements with maxOccurs="1" -->
               </xs:choice>
            </xs:sequence>
         </xs:complexType>
      </xs:schema>
   </types>
</definitions>

The Equipment generated property should not have a limit constraint as its definition have maxOccurs="unbouded"
But the generated setter setEquipment of VehicleType had the following condition.

// validation for constraint: choiceMaxOccurs(1)
if (is_array($equipment) && count($equipment) > 1) {
    throw new InvalidArgumentException(sprintf('Invalid count of %s, the number of elements contained by the property must be less than or equal to 1', count($equipment)), __LINE__);
}

The others elements of the choice block all have maxOccurs="1" so I guess it's just a misread of the property of each choice element.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions