From ac04833243c583aa84e64b671ca5ba0fc2347d79 Mon Sep 17 00:00:00 2001 From: gggeek Date: Tue, 17 Jan 2023 12:06:17 +0000 Subject: [PATCH] add Server::setDispatchMap; comments --- src/Client.php | 1 + src/Server.php | 22 ++++++++++++++++------ src/Value.php | 2 +- 3 files changed, 18 insertions(+), 7 deletions(-) diff --git a/src/Client.php b/src/Client.php index 14c9e52b..f4128d4c 100644 --- a/src/Client.php +++ b/src/Client.php @@ -752,6 +752,7 @@ class Client } // Only create the payload if it was not created previously + /// @todo what if the request's payload was created with a different encoding? if (empty($req->payload)) { $req->serialize($this->request_charset_encoding); } diff --git a/src/Server.php b/src/Server.php index b4136d53..6beca1a8 100644 --- a/src/Server.php +++ b/src/Server.php @@ -195,13 +195,11 @@ class Server $this->accepted_charset_encodings = array('UTF-8', 'ISO-8859-1', 'US-ASCII'); // dispMap is a dispatch array of methods mapped to function names and signatures. - // If a method doesn't appear in the map then an unknown method error is generated - /* milosch - changed to make passing dispMap optional. - * instead, you can use the class add_to_map() function - * to add functions manually (borrowed from SOAPX4) - */ + // If a method doesn't appear in the map then an unknown method error is generated. + // milosch - changed to make passing dispMap optional. Instead, you can use the class add_to_map() function + // to add functions manually (borrowed from SOAPX4) if ($dispatchMap) { - $this->dmap = $dispatchMap; + $this->setDispatchMap($dispatchMap); if ($serviceNow) { $this->service(); } @@ -318,6 +316,7 @@ class Server /// @todo try to move this injection to the resp. constructor or use a non-deprecated access method. Or, even /// better: just avoid setting this, and set debug info of the received http request in the request /// object instead? It's not like the developer misses access to _SERVER, _COOKIES though... + /// Last but not least: the raw data might be of use to handler functions - but in decompressed form... $resp->raw_data = $rawData; } @@ -332,6 +331,7 @@ class Server } // Do not create response serialization if it has already happened. Helps to build json magic + /// @todo what if the payload was created targeting a different charset than $respCharset? if (empty($resp->payload)) { $resp->serialize($respCharset); } @@ -941,6 +941,16 @@ class Server } + /** + * @param array $dmap + * @return $this + */ + public function setDispatchMap($dmap) + { + $this->dmap = $dmap; + return $this; + } + /** * @return array[] */ diff --git a/src/Value.php b/src/Value.php index acc1609e..63f70225 100644 --- a/src/Value.php +++ b/src/Value.php @@ -371,7 +371,7 @@ class Value implements \Countable, \IteratorAggregate, \ArrayAccess /** * Returns the xml representation of the value. XML prologue not included. * - * @param string $charsetEncoding the charset to be used for serialization. if null, US-ASCII is assumed + * @param string $charsetEncoding the charset to be used for serialization. If null, US-ASCII is assumed * @return string */ public function serialize($charsetEncoding = '') -- 2.47.0