Clean up old-API code
[plcapi.git] / src / Server.php
index 70b45de..07cfb9b 100644 (file)
@@ -51,7 +51,8 @@ class Server
     public $allow_system_funcs = true;
     /**
      * List of charset encodings natively accepted for requests.
-     *  Set at constructor time.
+     * Set at constructor time.
+     * UNUSED so far...
      */
     public $accepted_charset_encodings = array();
     /**
@@ -347,7 +348,7 @@ class Server
     /**
      * Parse http headers received along with xmlrpc request. If needed, inflate request.
      *
-     * @return mixed null on success or a Response
+     * @return mixed Response|null on success or an error Response
      */
     protected function parseRequestHeaders(&$data, &$reqEncoding, &$respEncoding, &$respCompression)
     {
@@ -914,7 +915,7 @@ class Server
         if ($call->kindOf() != 'struct') {
             return static::_xmlrpcs_multicall_error('notstruct');
         }
-        $methName = @$call->structmem('methodName');
+        $methName = @$call['methodName'];
         if (!$methName) {
             return static::_xmlrpcs_multicall_error('nomethod');
         }
@@ -925,20 +926,18 @@ class Server
             return static::_xmlrpcs_multicall_error('recursion');
         }
 
-        $params = @$call->structmem('params');
+        $params = @$call['params'];
         if (!$params) {
             return static::_xmlrpcs_multicall_error('noparams');
         }
         if ($params->kindOf() != 'array') {
             return static::_xmlrpcs_multicall_error('notarray');
         }
-        $numParams = $params->arraysize();
 
         $req = new Request($methName->scalarval());
-        for ($i = 0; $i < $numParams; $i++) {
-            if (!$req->addParam($params->arraymem($i))) {
-                $i++;
-
+        foreach($params as $i => $param) {
+            if (!$req->addParam($param)) {
+                $i++; // for error message, we count params from 1
                 return static::_xmlrpcs_multicall_error(new Response(0,
                     PhpXmlRpc::$xmlrpcerr['incorrect_params'],
                     PhpXmlRpc::$xmlrpcstr['incorrect_params'] . ": probable xml error in param " . $i));
@@ -999,10 +998,8 @@ class Server
         // let accept a plain list of php parameters, beside a single xmlrpc msg object
         if (is_object($req)) {
             $calls = $req->getParam(0);
-            $numCalls = $calls->arraysize();
-            for ($i = 0; $i < $numCalls; $i++) {
-                $call = $calls->arraymem($i);
-                $result[$i] = static::_xmlrpcs_multicall_do_call($server, $call);
+            foreach($calls as $call) {
+                $result[] = static::_xmlrpcs_multicall_do_call($server, $call);
             }
         } else {
             $numCalls = count($req);