Skip to content

Implement request #55503: Extend __getTypes to support enumerations #18704

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jun 4, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions NEWS
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,8 @@ PHP NEWS
. Fix namespace handling of WSDL and XML schema in SOAP,
fixing at least GH-16320 and bug #68576. (nielsdos)
. Fixed bug #70951 (Segmentation fault on invalid WSDL cache). (nielsdos)
. Implement request #55503 (Extend __getTypes to support enumerations).
(nielsdos, datibbaw)

- Sockets:
. Added IPPROTO_ICMP/IPPROTO_ICMPV6 to create raw socket for ICMP usage.
Expand Down
3 changes: 3 additions & 0 deletions UPGRADING
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,9 @@ PHP 8.5 UPGRADE NOTES
IntlListFormatter::WIDTH_NARROW widths.
It is supported from icu 67.

- SOAP:
. Enumeration cases are now dumped in __getTypes().

- XSL:
. The $namespace argument of XSLTProcessor::getParameter(),
XSLTProcessor::setParameter() and XSLTProcessor::removeParameter()
Expand Down
16 changes: 16 additions & 0 deletions ext/soap/soap.c
Original file line number Diff line number Diff line change
Expand Up @@ -4404,6 +4404,22 @@ static void type_to_string(sdlTypePtr type, smart_str *buf, int level) /* {{{ */
smart_str_appendl(buf, "anyType ", sizeof("anyType ")-1);
}
smart_str_appendl(buf, type->name, strlen(type->name));

if (type->restrictions && type->restrictions->enumeration) {
zend_string *key;
bool first = true;

smart_str_appends(buf, " {");
ZEND_HASH_MAP_FOREACH_STR_KEY(type->restrictions->enumeration, key) {
if (first) {
first = false;
} else {
smart_str_appends(buf, ", ");
}
smart_str_append(buf, key);
} ZEND_HASH_FOREACH_END();
smart_str_appendc(buf, '}');
}
break;
case XSD_TYPEKIND_LIST:
smart_str_appendl(buf, "list ", 5);
Expand Down
4 changes: 2 additions & 2 deletions ext/soap/tests/bugs/bug42359.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ print_r($soap->__getTypes());
Array
(
[0] => list listItem {anonymous1}
[1] => string anonymous1
[2] => string enumItem
[1] => string anonymous1 {test1, test2}
[2] => string enumItem {test1, test2}
[3] => list listItem2 {enumItem}
)
16 changes: 16 additions & 0 deletions ext/soap/tests/req55503.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
--TEST--
Request #55503 (Extend __getTypes to support enumerations)
--EXTENSIONS--
soap
--INI--
soap.wsdl_cache_enabled=0
--FILE--
<?php
$client = new SoapClient(__DIR__.'/req55503.wsdl');
var_dump($client->__getTypes());
?>
--EXPECT--
array(1) {
[0]=>
string(102) "anyType PersonaMemberType {NEW, LIMITED, FREE, PAID_ACTIVE, TRIAL_ACTIVE, PAID_EXPIRED, TRIAL_EXPIRED}"
}
30 changes: 30 additions & 0 deletions ext/soap/tests/req55503.wsdl
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?xml version="1.0" encoding="UTF-8"?>
<definitions xmlns="http://schemas.xmlsoap.org/wsdl/" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" elementFormDefault="qualified">
<types>
<schema
xmlns="http://www.w3.org/2001/XMLSchema"
targetNamespace="http://soapinterop.org/types">
<simpleType name="PersonaMemberType">
<restriction base="xsd:string">
<enumeration value="NEW"/>
<enumeration value="LIMITED"/>
<enumeration value="FREE"/>
<enumeration value="PAID_ACTIVE"/>
<enumeration value="TRIAL_ACTIVE"/>
<enumeration value="PAID_EXPIRED"/>
<enumeration value="TRIAL_EXPIRED"/>
</restriction>
</simpleType>
</schema>
</types>
<portType name="testPortType">
</portType>
<binding name="testBinding" type="tns:testPortType">
<soap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http"/>
</binding>
<service name="test">
<port name="testPort" binding="tns:testBinding">
<soap:address location="http://localhost:81/test/interface.php?class=test"/>
</port>
</service>
</definitions>