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

Deprecated Warnings for Dynamic Properties #299

Closed tbreuss closed 11 months ago

tbreuss commented 11 months ago

Describe the bug

If in WSDLs attribute names are defined with hyphens, these leads to generated code like the following.

class CompanyNameType {
    protected ?string $HR_RC_Name = null;
    public function setHR_RC_Name(?string $hR_RC_Name = null) {
        $this->HR_RC_Name = $this->{'HR-RC-Name'} = $hR_RC_Name;
    }
}

Here we have the dynamic property by the name "HR-RC-Name".

With PHP 8.2 these dynamic properties (in the above context HR-RC-Name) lead to a PHP Deprecated Warning. More infos: https://php.watch/versions/8.2/dynamic-properties-deprecated

PHP Deprecated Warning: Creation of dynamic property [...] is deprecated

Possible solution

An easy solution could be, to add the PHP Attribute "AllowDynamicProperties" to the affected class.

#[\AllowDynamicProperties]
class CompanyNameType
{ }