Skip to content

ext-soap + unbounded elements + classmap + 1 element #11705

Open
@Hanmac

Description

@Hanmac

Description

The WSDL for this class:

<xsd:complexType name="resLFAType">
    <xsd:sequence>
        <xsd:element name="resInfo"	type="tns:resInfoType"></xsd:element>
        <xsd:element name="resLFAsucces" type="tns:LFAsuccesType" minOccurs="0" maxOccurs="unbounded"></xsd:element>
        <xsd:element name="resLFAerror" type="tns:LFAerrorType" minOccurs="0" maxOccurs="unbounded"></xsd:element>
    </xsd:sequence>
</xsd:complexType>
    

while using this SOAP classmap:

    protected static array $classMap = [
        'resInfoType' => ResInfoType::class,

        'resLFAType' => ResLFAType::class,

        'LFAsuccesType' => LFASuccessType::class,
        'LFAerrorType' => LFAErrorType::class,
    ];

while having this for ResLFAType:

<?php

class ResLFAType
{
    public ?ResInfoType $resInfo;

    /**
     * @var LFASuccessType[]
     */
    public array $resLFAsucces = [];
    /**
     * @var LFAErrorType[]
     */
    public array $resLFAerror = [];
}

When the SOAP service is responding with multiple resLFAsucces and/or resLFAerror, everything works fine

BUT when the SOAP service is responding with exactly one of resLFAsucces, then i get this Exception:

Cannot assign LFASuccessType to property ResLFAType::$resLFAsucces of type array

it seems to understand when getting multiple entries to assign them correctly to the property,
but it fails when only getting one object.

PHP Version

PHP 8.2.6

Operating System

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions