1
0
mirror of https://github.com/php/php-src.git synced 2026-03-24 00:02:20 +01:00

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

Co-authored-by: datibbaw <datibbaw@php.net>
This commit is contained in:
Niels Dossche
2025-06-04 17:46:57 +02:00
committed by GitHub
parent 690cde6903
commit f46f42b2b2
6 changed files with 69 additions and 2 deletions

2
NEWS
View File

@@ -190,6 +190,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.

View File

@@ -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()

View File

@@ -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);

View File

@@ -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}
)

View File

@@ -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}"
}

View File

@@ -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>