Skip to content

Generated types that use enums have wrong parameters #594

@Harkonn

Description

@Harkonn

Bug Report

Q A
BC Break yes/no
Version 4.4.1

Summary

The generated types that use an enum of type string create a fatal error exception:

Got error 'PHP message: PHP Fatal error:  Declaration of namespace\\Type\\CodeNachrichtAntwortCode::getCode(): namespace\\Type\\CodelisteNachrichtAntwortCode must be compatible with namespace\\Type\\Code::getCode(): string

Current behavior

The generated code for the complexType Code.NachrichtAntwortCode has an element named code of type xzufi:Codeliste.NachrichtAntwortCode in the imported schema xzufi-baukasten.xsd (which itself is imported in xzufi-leistungen.xsd). It is an enumeration of strings and the following type gets generated:

enum CodelisteNachrichtAntwortCode: string {
    case Value_000 = '000';
    case Value_001 = '001';
    case Value_101 = '101';
}

The get- and with-methods want to have an object of this type:

class CodeNachrichtAntwortCode extends Code
{
    // stripped code
    /**
     * @return namespace\Type\CodelisteNachrichtAntwortCode
     */
    public function getCode() : namespace\Type\CodelisteNachrichtAntwortCode
    {
        return $this->code;
    }

    /**
     * @param namespace\Type\CodelisteNachrichtAntwortCode $code
     * @return static
     */
    public function withCode(namespace\Type\CodelisteNachrichtAntwortCode $code) : static
    {
        $new = clone $this;
        $new->code = $code;

        return $new;
    }

}

My IDE is already complaining about these types (Return type declaration must be compatible with Code->getCode() : string ). Also the real values are just the strings in the soap-communication:

<xzufi:antwortrueckgabecode listURI="urn:xoev-de:fim:codeliste:xzufi.nachrichtantwortcode" listVersionID="1.1">
	<code>000</code>
</xzufi:antwortrueckgabecode>

How to reproduce

  1. Run ./vendor/bin/soap-client generate:types --config config/soap-client.php for https://xzufi-v2-2-0-nw-schul.infodienste.de/?wsdl (warning: it will generate 1400 files...)
  2. Look into the type for CodeNachrichtAntwortCode.php and see that the method getCode() returns \namespace\Type\CodelisteNachrichtAntwortCode and withCode expects \namespace\Type\CodelisteNachrichtAntwortCode

Expected behavior

The generated values for the get- and with- methods should be of the type of the enums (in my case string) instead of expecting the generated-enum-type class as a value.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions