Skip to content

Commit 24cb5bd

Browse files
nielsdosdatibbaw
andcommitted
Implement request #55503: Extend __getTypes to support enumerations
I ported the patch to 8.5. Co-authored-by: datibbaw <[email protected]>
1 parent 3cb7d1b commit 24cb5bd

File tree

6 files changed

+61
-2
lines changed

6 files changed

+61
-2
lines changed

NEWS

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,8 @@ PHP NEWS
187187
. Fix namespace handling of WSDL and XML schema in SOAP,
188188
fixing at least GH-16320 and bug #68576. (nielsdos)
189189
. Fixed bug #70951 (Segmentation fault on invalid WSDL cache). (nielsdos)
190+
. Implement request #55503 (Extend __getTypes to support enumerations).
191+
(nielsdos, datibbaw)
190192

191193
- Sockets:
192194
. Added IPPROTO_ICMP/IPPROTO_ICMPV6 to create raw socket for ICMP usage.

UPGRADING

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,9 @@ PHP 8.5 UPGRADE NOTES
194194
IntlListFormatter::WIDTH_NARROW widths.
195195
It is supported from icu 67.
196196

197+
- SOAP:
198+
. Enumeration cases are now dumped in __getTypes().
199+
197200
- XSL:
198201
. The $namespace argument of XSLTProcessor::getParameter(),
199202
XSLTProcessor::setParameter() and XSLTProcessor::removeParameter()

ext/soap/soap.c

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4404,6 +4404,22 @@ static void type_to_string(sdlTypePtr type, smart_str *buf, int level) /* {{{ */
44044404
smart_str_appendl(buf, "anyType ", sizeof("anyType ")-1);
44054405
}
44064406
smart_str_appendl(buf, type->name, strlen(type->name));
4407+
4408+
if (type->restrictions && type->restrictions->enumeration) {
4409+
zend_string *key;
4410+
bool first = true;
4411+
4412+
smart_str_appends(buf, " {");
4413+
ZEND_HASH_MAP_FOREACH_STR_KEY(type->restrictions->enumeration, key) {
4414+
if (first) {
4415+
first = false;
4416+
} else {
4417+
smart_str_appends(buf, ", ");
4418+
}
4419+
smart_str_append(buf, key);
4420+
} ZEND_HASH_FOREACH_END();
4421+
smart_str_appendc(buf, '}');
4422+
}
44074423
break;
44084424
case XSD_TYPEKIND_LIST:
44094425
smart_str_appendl(buf, "list ", 5);

ext/soap/tests/bugs/bug42359.phpt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ print_r($soap->__getTypes());
1313
Array
1414
(
1515
[0] => list listItem {anonymous1}
16-
[1] => string anonymous1
17-
[2] => string enumItem
16+
[1] => string anonymous1 {test1, test2}
17+
[2] => string enumItem {test1, test2}
1818
[3] => list listItem2 {enumItem}
1919
)

ext/soap/tests/req55503.phpt

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
--TEST--
2+
Request #55503 (Extend __getTypes to support enumerations)
3+
--EXTENSIONS--
4+
soap
5+
--FILE--
6+
<?php
7+
$client = new SoapClient(__DIR__.'/req55503.wsdl');
8+
var_dump($client->__getTypes());
9+
?>
10+
--EXPECT--
11+
array(1) {
12+
[0]=>
13+
string(102) "anyType PersonaMemberType {NEW, LIMITED, FREE, PAID_ACTIVE, TRIAL_ACTIVE, PAID_EXPIRED, TRIAL_EXPIRED}"
14+
}

ext/soap/tests/req55503.wsdl

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<definitions xmlns="http://schemas.xmlsoap.org/wsdl/" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" elementFormDefault="qualified">
3+
<types>
4+
<schema
5+
xmlns="http://www.w3.org/2001/XMLSchema"
6+
targetNamespace="http://soapinterop.org/types">
7+
<simpleType name="PersonaMemberType">
8+
<restriction base="xsd:string">
9+
<enumeration value="NEW"/>
10+
<enumeration value="LIMITED"/>
11+
<enumeration value="FREE"/>
12+
<enumeration value="PAID_ACTIVE"/>
13+
<enumeration value="TRIAL_ACTIVE"/>
14+
<enumeration value="PAID_EXPIRED"/>
15+
<enumeration value="TRIAL_EXPIRED"/>
16+
</restriction>
17+
</simpleType>
18+
</schema>
19+
</types>
20+
<portType name="testPortType">
21+
</portType>
22+
<binding name="testBinding" type="tns:testPortType">
23+
</binding>
24+
</definitions>

0 commit comments

Comments
 (0)