php / php/php-src

ext-soap + unbounded elements + classmap + 1 element

Open
#11,705 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Bug Extension: soap Status: Needs Triage
Dominant language
C
Stars
40.4k
Forks
8.1k
Avg merge
2d 13h
Merged PRs (30d)
96

Description

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

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the failure using the provided WSDL, PHP classmap, ResLFAType definition, and a response containing exactly one resLFAsucces element. Trace the ext-soap deserialization path for unbounded elements and compare singleton handling with multiple elements. Done means a single response populates the typed array without the assignment exception, with a regression test covering the case.

Written by the indexing model from the issue text.

Assessment

Tech stack
php
Domain
api
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.