review injection of helpers
authorgggeek <giunta.gaetano@gmail.com>
Wed, 18 Jan 2023 09:42:57 +0000 (09:42 +0000)
committergggeek <giunta.gaetano@gmail.com>
Wed, 18 Jan 2023 09:42:57 +0000 (09:42 +0000)
src/Client.php
src/Helper/XMLParser.php
src/PhpXmlRpc.php
src/Response.php

index 24b4deb..cfe82c9 100644 (file)
@@ -2,7 +2,7 @@
 
 namespace PhpXmlRpc;
 
-use PhpXmlRpc\Helper\Charset;
+//use PhpXmlRpc\Helper\Charset;
 use PhpXmlRpc\Helper\Logger;
 use PhpXmlRpc\Helper\XMLParser;
 
index 7699f62..83dee35 100644 (file)
@@ -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')) {
index 8781e7b..c6160c5 100644 (file)
@@ -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');
     }
 
index c390232..760e782 100644 (file)
@@ -169,7 +169,7 @@ class Response
             $result .= "<fault>\n" .
                 "<value>\n<struct><member><name>faultCode</name>\n<value><int>" . $this->errno .
                 "</int></value>\n</member>\n<member>\n<name>faultString</name>\n<value><string>" .
-                Charset::instance()->encodeEntities($this->errstr, PhpXmlRpc::$xmlrpc_internalencoding, $charsetEncoding) . "</string></value>\n</member>\n" .
+                $this->getCharsetEncoder()->encodeEntities($this->errstr, PhpXmlRpc::$xmlrpc_internalencoding, $charsetEncoding) . "</string></value>\n</member>\n" .
                 "</struct>\n</value>\n</fault>";
         } else {
             if (!is_object($this->val) || !is_a($this->val, 'PhpXmlRpc\Value')) {