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

Incorrect default value for integer attribute #300

Closed datWeazel closed 11 months ago

datWeazel commented 11 months ago

Describe the bug

<xs:attribute name="DecimalPlaces" type="xs:nonNegativeInteger" use="optional" default="0">
    <xs:annotation>
        <xs:documentation xml:lang="en">Indicates the number of decimal places for a particular currency.</xs:documentation>
    </xs:annotation>
</xs:attribute>

This Attribute results in a constructor argument of the corresponding php class that looks like this: ?int $decimalPlaces = '0' Obivously this results in an error since '0' is a string.

The php docs comment is wrong aswell: * @param int $decimalPlaces Should be int|null.

mikaelcom commented 11 months ago

Hi, I'm surprised because it seems to work as expected such as in https://gist.github.com/mikaelcom/6e9139088377338f8f8961c81b223355 for the NewsRequest struct.

It could have become trom the type nonNegativeInteger but it's mapped as int such as type unsignedInt.

Do you have any custom XSD types defined? Can you provide the WSDL url/file?

datWeazel commented 11 months ago

Not sure if I'm allowed to share the WSDL publicly. Any way to send it to you directly?

mikaelcom commented 11 months ago

Yes, at contact@mikael-delsol.fr.

mikaelcom commented 11 months ago

Well received and bug well reproduced, fixed by PR #302