Fix ArrayIterator interface implementation; remove usage of arraysize(), structsize...
[plcapi.git] / src / Encoder.php
index e19dada..86e518e 100644 (file)
@@ -39,7 +39,7 @@ class Encoder
                         case 'dateTime.iso8601':
                             $xmlrpcVal->scalar = $val;
                             $xmlrpcVal->type = 'datetime';
-                            $xmlrpcVal->timestamp = \PhpXmlRpc\Helper\Date::iso8601_decode($val);
+                            $xmlrpcVal->timestamp = \PhpXmlRpc\Helper\Date::iso8601Decode($val);
 
                             return $xmlrpcVal;
                         case 'base64':
@@ -71,7 +71,7 @@ class Encoder
 
                 return $xmlrpcVal->scalarval();
             case 'array':
-                $size = $xmlrpcVal->arraysize();
+                $size = $xmlrpcVal->count();
                 $arr = array();
                 for ($i = 0; $i < $size; $i++) {
                     $arr[] = $this->decode($xmlrpcVal->arraymem($i), $options);
@@ -79,7 +79,6 @@ class Encoder
 
                 return $arr;
             case 'struct':
-                $xmlrpcVal->structreset();
                 // If user said so, try to rebuild php objects for specific struct vals.
                 /// @todo should we raise a warning for class not found?
                 // shall we check for proper subclass of xmlrpc value instead of
@@ -88,14 +87,14 @@ class Encoder
                     && class_exists($xmlrpcVal->_php_class)
                 ) {
                     $obj = @new $xmlrpcVal->_php_class();
-                    while (list($key, $value) = $xmlrpcVal->structeach()) {
+                    foreach ($xmlrpcVal as $key => $value) {
                         $obj->$key = $this->decode($value, $options);
                     }
 
                     return $obj;
                 } else {
                     $arr = array();
-                    while (list($key, $value) = $xmlrpcVal->structeach()) {
+                    foreach ($xmlrpcVal as $key => $value) {
                         $arr[$key] = $this->decode($value, $options);
                     }
 
@@ -105,7 +104,7 @@ class Encoder
                 $paramCount = $xmlrpcVal->getNumParams();
                 $arr = array();
                 for ($i = 0; $i < $paramCount; $i++) {
-                    $arr[] = $this->decode($xmlrpcVal->getParam($i));
+                    $arr[] = $this->decode($xmlrpcVal->getParam($i), $options);
                 }
 
                 return $arr;
@@ -230,7 +229,7 @@ class Encoder
      *
      * @return mixed false on error, or an instance of either Value, Request or Response
      */
-    public function decode_xml($xmlVal, $options = array())
+    public function decodeXml($xmlVal, $options = array())
     {
         // 'guestimate' encoding
         $valEncoding = XMLParser::guessEncoding('', $xmlVal);
@@ -300,12 +299,12 @@ class Encoder
 
                 return $r;
             case 'methodcall':
-                $m = new Request($xmlRpcParser->_xh['method']);
+                $req = new Request($xmlRpcParser->_xh['method']);
                 for ($i = 0; $i < count($xmlRpcParser->_xh['params']); $i++) {
-                    $m->addParam($xmlRpcParser->_xh['params'][$i]);
+                    $req->addParam($xmlRpcParser->_xh['params'][$i]);
                 }
 
-                return $m;
+                return $req;
             case 'value':
                 return $xmlRpcParser->_xh['value'];
             default: