rename variables and clean up comments
authorgggeek <giunta.gaetano@gmail.com>
Sun, 17 May 2015 15:55:46 +0000 (16:55 +0100)
committergggeek <giunta.gaetano@gmail.com>
Sun, 17 May 2015 15:55:46 +0000 (16:55 +0100)
src/Client.php
src/Server.php
src/Wrapper.php

index 214d970..21060e8 100644 (file)
@@ -352,7 +352,7 @@ class Client
         }
 
         if (is_array($req)) {
-            // $msg is an array of Requests
+            // $req is an array of Requests
             $r = $this->multicall($req, $timeout, $method);
 
             return $r;
@@ -634,7 +634,7 @@ class Client
      * Requires curl to be built into PHP
      * NB: CURL versions before 7.11.10 cannot use proxy to talk to https servers!
      *
-     * @param Request $msg
+     * @param Request $req
      * @param string $server
      * @param int $port
      * @param int $timeout
@@ -657,7 +657,7 @@ class Client
      * @param int $sslVersion
      * @return Response
      */
-    protected function sendPayloadCURL($msg, $server, $port, $timeout = 0, $username = '',
+    protected function sendPayloadCURL($req, $server, $port, $timeout = 0, $username = '',
                                      $password = '', $authType = 1, $cert = '', $certPass = '', $caCert = '', $caCertDir = '',
                                      $proxyHost = '', $proxyPort = 0, $proxyUsername = '', $proxyPassword = '', $proxyAuthType = 1, $method = 'https',
                                      $keepAlive = false, $key = '', $keyPass = '', $sslVersion = 0)
@@ -684,12 +684,12 @@ class Client
         }
 
         // Only create the payload if it was not created previously
-        if (empty($msg->payload)) {
-            $msg->createPayload($this->request_charset_encoding);
+        if (empty($req->payload)) {
+            $req->createPayload($this->request_charset_encoding);
         }
 
         // Deflate request body and set appropriate request headers
-        $payload = $msg->payload;
+        $payload = $req->payload;
         if (function_exists('gzdeflate') && ($this->request_compression == 'gzip' || $this->request_compression == 'deflate')) {
             if ($this->request_compression == 'gzip') {
                 $a = @gzencode($payload);
@@ -750,7 +750,7 @@ class Client
             }
         }
         // extra headers
-        $headers = array('Content-Type: ' . $msg->content_type, 'Accept-Charset: ' . implode(',', $this->accepted_charset_encodings));
+        $headers = array('Content-Type: ' . $req->content_type, 'Accept-Charset: ' . implode(',', $this->accepted_charset_encodings));
         // if no keepalive is wanted, let the server know it in advance
         if (!$keepAlive) {
             $headers[] = 'Connection: close';
@@ -865,7 +865,7 @@ class Client
             if (!$keepAlive) {
                 curl_close($curl);
             }
-            $resp = $msg->parseResponse($result, true, $this->return_type);
+            $resp = $req->parseResponse($result, true, $this->return_type);
             // if we got back a 302, we can not reuse the curl handle for later calls
             if ($resp->faultCode() == PhpXmlRpc::$xmlrpcerr['http_error'] && $keepAlive) {
                 curl_close($curl);
index 930edff..8a2f511 100644 (file)
@@ -12,16 +12,16 @@ class Server
      */
     protected $dmap = array();
     /**
-     * Defines how functions in dmap will be invoked: either using an xmlrpc msg object
+     * Defines how functions in dmap will be invoked: either using an xmlrpc request object
      * or plain php values.
-     * valid strings are 'xmlrpcvals', 'phpvals' or 'epivals'
+     * Valid strings are 'xmlrpcvals', 'phpvals' or 'epivals'
      */
     public $functions_parameters_type = 'xmlrpcvals';
     /**
      * Option used for fine-tuning the encoding the php values returned from
      * functions registered in the dispatch map when the functions_parameters_types
      * member is set to 'phpvals'
-     * @see php_xmlrpc_encode for a list of values
+     * @see Encoder::encode for a list of values
      */
     public $phpvals_encoding_options = array('auto_dates');
     /**
@@ -30,7 +30,7 @@ class Server
      */
     public $debug = 1;
     /**
-     * Controls behaviour of server when invoked user function throws an exception:
+     * Controls behaviour of server when the invoked user function throws an exception:
      * 0 = catch it and return an 'internal error' xmlrpc response (default)
      * 1 = catch it and return an xmlrpc response with the error corresponding to the exception
      * 2 = allow the exception to float to the upper layers
@@ -39,16 +39,20 @@ class Server
     /**
      * When set to true, it will enable HTTP compression of the response, in case
      * the client has declared its support for compression in the request.
+     * Set at constructor time.
      */
     public $compress_response = false;
     /**
-     * List of http compression methods accepted by the server for requests.
+     * List of http compression methods accepted by the server for requests. Set at constructor time.
      * NB: PHP supports deflate, gzip compressions out of the box if compiled w. zlib
      */
     public $accepted_compression = array();
     /// shall we serve calls to system.* methods?
     public $allow_system_funcs = true;
-    /// list of charset encodings natively accepted for requests
+    /**
+     * List of charset encodings natively accepted for requests.
+     *  Set at constructor time.
+     */
     public $accepted_charset_encodings = array();
     /**
      * charset encoding to be used for response.
@@ -75,7 +79,7 @@ class Server
 
     /**
      * @param array $dispatchMap the dispatch map with definition of exposed services
-     * @param boolean $servicenow set to false to prevent the server from running upon construction
+     * @param boolean $serviceNow set to false to prevent the server from running upon construction
      */
     public function __construct($dispatchMap = null, $serviceNow = true)
     {
@@ -89,15 +93,12 @@ class Server
         // by default the xml parser can support these 3 charset encodings
         $this->accepted_charset_encodings = array('UTF-8', 'ISO-8859-1', 'US-ASCII');
 
-        // dispMap is a dispatch array of methods
-        // mapped to function names and signatures
-        // if a method
-        // doesn't appear in the map then an unknown
-        // method error is generated
+        // dispMap is a dispatch array of methods mapped to function names and signatures.
+        // If a method doesn't appear in the map then an unknown method error is generated
         /* milosch - changed to make passing dispMap optional.
-            * instead, you can use the class add_to_map() function
-            * to add functions manually (borrowed from SOAPX4)
-            */
+        * instead, you can use the class add_to_map() function
+        * to add functions manually (borrowed from SOAPX4)
+        */
         if ($dispatchMap) {
             $this->dmap = $dispatchMap;
             if ($serviceNow) {
@@ -291,12 +292,12 @@ class Server
     /**
      * Verify type and number of parameters received against a list of known signatures.
      *
-     * @param array $in array of either xmlrpc value objects or xmlrpc type definitions
-     * @param array $sig array of known signatures to match against
+     * @param array|Request $in array of either xmlrpc value objects or xmlrpc type definitions
+     * @param array $sigs array of known signatures to match against
      *
      * @return array
      */
-    protected function verifySignature($in, $sig)
+    protected function verifySignature($in, $sigs)
     {
         // check each possible signature in turn
         if (is_object($in)) {
@@ -304,8 +305,8 @@ class Server
         } else {
             $numParams = count($in);
         }
-        foreach ($sig as $cursig) {
-            if (count($cursig) == $numParams + 1) {
+        foreach ($sigs as $curSig) {
+            if (count($curSig) == $numParams + 1) {
                 $itsOK = 1;
                 for ($n = 0; $n < $numParams; $n++) {
                     if (is_object($in)) {
@@ -320,10 +321,10 @@ class Server
                     }
 
                     // param index is $n+1, as first member of sig is return type
-                    if ($pt != $cursig[$n + 1] && $cursig[$n + 1] != Value::$xmlrpcValue) {
+                    if ($pt != $curSig[$n + 1] && $curSig[$n + 1] != Value::$xmlrpcValue) {
                         $itsOK = 0;
                         $pno = $n + 1;
-                        $wanted = $cursig[$n + 1];
+                        $wanted = $curSig[$n + 1];
                         $got = $pt;
                         break;
                     }
@@ -816,11 +817,11 @@ class Server
             if (isset($dmap[$methName]['signature'])) {
                 $sigs = array();
                 foreach ($dmap[$methName]['signature'] as $inSig) {
-                    $cursig = array();
+                    $curSig = array();
                     foreach ($inSig as $sig) {
-                        $cursig[] = new Value($sig, 'string');
+                        $curSig[] = new Value($sig, 'string');
                     }
-                    $sigs[] = new Value($cursig, 'array');
+                    $sigs[] = new Value($curSig, 'array');
                 }
                 $r = new Response(new Value($sigs, 'array'));
             } else {
@@ -903,9 +904,9 @@ class Server
         }
         $numParams = $params->arraysize();
 
-        $msg = new Request($methName->scalarval());
+        $req = new Request($methName->scalarval());
         for ($i = 0; $i < $numParams; $i++) {
-            if (!$msg->addParam($params->arraymem($i))) {
+            if (!$req->addParam($params->arraymem($i))) {
                 $i++;
 
                 return static::_xmlrpcs_multicall_error(new Response(0,
@@ -914,7 +915,7 @@ class Server
             }
         }
 
-        $result = $server->execute($msg);
+        $result = $server->execute($req);
 
         if ($result->faultCode() != 0) {
             return static::_xmlrpcs_multicall_error($result); // Method returned fault.
index fe4fae7..6cd2538 100644 (file)
@@ -707,14 +707,14 @@ class Wrapper
         }
         $debug = isset($extraOptions['debug']) ? ($extraOptions['debug']) : 0;
 
-        $msgClass = $namespace . 'Request';
+        $reqClass = $namespace . 'Request';
         $valClass = $namespace . 'Value';
         $decoderClass = $namespace . 'Encoder';
 
-        $msg = new $msgClass('system.methodSignature');
-        $msg->addparam(new $valClass($methodName));
+        $req = new $reqClass('system.methodSignature');
+        $req->addparam(new $valClass($methodName));
         $client->setDebug($debug);
-        $response = $client->send($msg, $timeout, $protocol);
+        $response = $client->send($req, $timeout, $protocol);
         if ($response->faultCode()) {
             error_log('XML-RPC: could not retrieve method signature from remote server for method ' . $methodName);
 
@@ -748,9 +748,9 @@ class Wrapper
                 // if in 'offline' mode, get method description too.
                 // in online mode, favour speed of operation
                 if (!$buildIt) {
-                    $msg = new $msgClass('system.methodHelp');
-                    $msg->addparam(new $valClass($methodName));
-                    $response = $client->send($msg, $timeout, $protocol);
+                    $req = new $reqClass('system.methodHelp');
+                    $req->addparam(new $valClass($methodName));
+                    $response = $client->send($req, $timeout, $protocol);
                     if (!$response->faultCode()) {
                         $mDesc = $response->value();
                         if ($client->return_type != 'phpvals') {
@@ -820,12 +820,12 @@ class Wrapper
         $prefix = isset($extraOptions['prefix']) ? $extraOptions['prefix'] : 'xmlrpc';
         $namespace = '\\PhpXmlRpc\\';
 
-        $msgClass = $namespace . 'Request';
+        $reqClass = $namespace . 'Request';
         //$valClass = $prefix.'val';
         $decoderClass = $namespace . 'Encoder';
 
-        $msg = new $msgClass('system.listMethods');
-        $response = $client->send($msg, $timeout, $protocol);
+        $req = new $reqClass('system.listMethods');
+        $response = $client->send($req, $timeout, $protocol);
         if ($response->faultCode()) {
             error_log('XML-RPC: could not retrieve method list from remote server');