Implement interface ArrayAccess in the Value class
[plcapi.git] / src / Encoder.php
index f97096e..1605418 100644 (file)
@@ -71,15 +71,16 @@ 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);
+                //for ($i = 0; $i < $size; $i++) {
+                foreach($xmlrpcVal as $value) {
+                    //$arr[] = $this->decode($xmlrpcVal->arraymem($i), $options);
+                    $arr[] = $this->decode($value, $options);
                 }
 
                 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 +89,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);
                     }
 
@@ -291,8 +292,10 @@ class Encoder
             case 'methodresponse':
                 $v = &$xmlRpcParser->_xh['value'];
                 if ($xmlRpcParser->_xh['isf'] == 1) {
-                    $vc = $v->structmem('faultCode');
-                    $vs = $v->structmem('faultString');
+                    //$vc = $v->structmem('faultCode');
+                    //$vs = $v->structmem('faultString');
+                    $vc = $v['faultCode'];
+                    $vs = $v['faultString'];
                     $r = new Response(0, $vc->scalarval(), $vs->scalarval());
                 } else {
                     $r = new Response($v);