From f46f42b2b2de3668d6e2b8d8efc32dd9285b9026 Mon Sep 17 00:00:00 2001 From: Niels Dossche <7771979+nielsdos@users.noreply.github.com> Date: Wed, 4 Jun 2025 17:46:57 +0200 Subject: [PATCH] Implement request #55503: Extend __getTypes to support enumerations (#18704) Co-authored-by: datibbaw --- NEWS | 2 ++ UPGRADING | 3 +++ ext/soap/soap.c | 16 ++++++++++++++++ ext/soap/tests/bugs/bug42359.phpt | 4 ++-- ext/soap/tests/req55503.phpt | 16 ++++++++++++++++ ext/soap/tests/req55503.wsdl | 30 ++++++++++++++++++++++++++++++ 6 files changed, 69 insertions(+), 2 deletions(-) create mode 100644 ext/soap/tests/req55503.phpt create mode 100644 ext/soap/tests/req55503.wsdl diff --git a/NEWS b/NEWS index 8427273c9d9..24d617d0c79 100644 --- a/NEWS +++ b/NEWS @@ -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. diff --git a/UPGRADING b/UPGRADING index 8f8b7e7685e..ef6739c3da9 100644 --- a/UPGRADING +++ b/UPGRADING @@ -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() diff --git a/ext/soap/soap.c b/ext/soap/soap.c index 094730b88f4..e0577ac648c 100644 --- a/ext/soap/soap.c +++ b/ext/soap/soap.c @@ -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); diff --git a/ext/soap/tests/bugs/bug42359.phpt b/ext/soap/tests/bugs/bug42359.phpt index 0cb4f75c69b..f717561e7ca 100644 --- a/ext/soap/tests/bugs/bug42359.phpt +++ b/ext/soap/tests/bugs/bug42359.phpt @@ -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} ) diff --git a/ext/soap/tests/req55503.phpt b/ext/soap/tests/req55503.phpt new file mode 100644 index 00000000000..ac3c8627048 --- /dev/null +++ b/ext/soap/tests/req55503.phpt @@ -0,0 +1,16 @@ +--TEST-- +Request #55503 (Extend __getTypes to support enumerations) +--EXTENSIONS-- +soap +--INI-- +soap.wsdl_cache_enabled=0 +--FILE-- +__getTypes()); +?> +--EXPECT-- +array(1) { + [0]=> + string(102) "anyType PersonaMemberType {NEW, LIMITED, FREE, PAID_ACTIVE, TRIAL_ACTIVE, PAID_EXPIRED, TRIAL_EXPIRED}" +} diff --git a/ext/soap/tests/req55503.wsdl b/ext/soap/tests/req55503.wsdl new file mode 100644 index 00000000000..91ac62c8bc0 --- /dev/null +++ b/ext/soap/tests/req55503.wsdl @@ -0,0 +1,30 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + +