From: gggeek Date: Wed, 18 Jan 2023 09:42:57 +0000 (+0000) Subject: review injection of helpers X-Git-Tag: 4.10.0~133 X-Git-Url: http://git.onelab.eu/?a=commitdiff_plain;h=4b8cf15fb4d3364760773e9de006fce9624123fe;p=plcapi.git review injection of helpers --- diff --git a/src/Client.php b/src/Client.php index 24b4deb0..cfe82c9c 100644 --- a/src/Client.php +++ b/src/Client.php @@ -2,7 +2,7 @@ namespace PhpXmlRpc; -use PhpXmlRpc\Helper\Charset; +//use PhpXmlRpc\Helper\Charset; use PhpXmlRpc\Helper\Logger; use PhpXmlRpc\Helper\XMLParser; diff --git a/src/Helper/XMLParser.php b/src/Helper/XMLParser.php index 7699f621..83dee352 100644 --- a/src/Helper/XMLParser.php +++ b/src/Helper/XMLParser.php @@ -53,7 +53,7 @@ class XMLParser 'ac' => '', 'stack' => array(), 'valuestack' => array(), - + 'lv' => 0, 'isf' => 0, 'isf_reason' => '', 'value' => null, @@ -134,6 +134,8 @@ class XMLParser * the constructor. String-key options are used independently * @return void the caller has to look into $this->_xh to find the results * @throws \Exception this can happen if a callback function is set and it does throw (i.e. we do not catch exceptions) + * + * @todo refactor? we could 1. return the parsed data structure, and 2. move $returnType and $accept into options */ public function parse($data, $returnType = self::RETURN_XMLRPCVALS, $accept = 3, $options = array()) { @@ -141,7 +143,7 @@ class XMLParser 'ac' => '', 'stack' => array(), 'valuestack' => array(), - + 'lv' => 0, 'isf' => 0, 'isf_reason' => '', 'value' => null, @@ -170,7 +172,7 @@ class XMLParser } foreach ($mergedOptions as $key => $val) { - if (is_string($key)) { + if (is_string($key) && !ctype_digit($key)) { switch($key) { case 'target_charset': if (function_exists('mb_convert_encoding')) { diff --git a/src/PhpXmlRpc.php b/src/PhpXmlRpc.php index 8781e7b9..c6160c5c 100644 --- a/src/PhpXmlRpc.php +++ b/src/PhpXmlRpc.php @@ -2,6 +2,8 @@ namespace PhpXmlRpc; +use PhpXmlRpc\Helper\Charset; + /** * Manages global configuration for operation of the library. */ @@ -177,7 +179,7 @@ class PhpXmlRpc } } - $charset = Helper\Charset::instance(); + $charset = Charset::instance(); $GLOBALS['xml_iso88591_Entities'] = $charset->getEntities('iso88591'); } diff --git a/src/Response.php b/src/Response.php index c3902325..760e7820 100644 --- a/src/Response.php +++ b/src/Response.php @@ -169,7 +169,7 @@ class Response $result .= "\n" . "\nfaultCode\n" . $this->errno . "\n\n\nfaultString\n" . - Charset::instance()->encodeEntities($this->errstr, PhpXmlRpc::$xmlrpc_internalencoding, $charsetEncoding) . "\n\n" . + $this->getCharsetEncoder()->encodeEntities($this->errstr, PhpXmlRpc::$xmlrpc_internalencoding, $charsetEncoding) . "\n\n" . "\n\n"; } else { if (!is_object($this->val) || !is_a($this->val, 'PhpXmlRpc\Value')) {