Skip to content

SoapClient can't convert BackedEnum to scalar value #15711

Closed
@MrMeshok

Description

Description

The following code:

<?php
enum TestBackedEnum: string
{
    case First = 'first';
}

$client = new SoapClient('https://raw.githubusercontent.com/php/php-src/master/ext/soap/tests/classmap.wsdl');

$book = new stdClass();
$book->a = TestBackedEnum::First;
$book->b = '';

$client->dotest($book);

Resulted in this output:

PHP Fatal error:  Uncaught Error: Object of class TestBackedEnum could not be converted to string

But I expected this output instead:

No errors

PHP Version

PHP 8.3.11

Operating System

No response

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