[php-src] Issue #11705: SOAP + unbounded elements + classmap + 1 element

From: Date: Fri, 14 Jul 2023 10:04:36 +0000
Subject: [php-src] Issue #11705: SOAP + unbounded elements + classmap + 1 element
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-244963@lists.php.net to get a copy of this message
Issue: https://github.com/php/php-src/issues/11705
Author: Hanmac

### Description

The WSDL for this class:

```xml
<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: 
```php

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

        'resLFAType' => ResLFAType::class,

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

while having this for ResLFAType:

```php
<?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_


Thread (1 message)

  • Hanmac
« previous php.bugs (#244963) next »