Add a warning to the manual; move more method names to camelCase; fix support for...
[plcapi.git] / lib / xmlrpc_wrappers.inc
index fc178dc..c9e3449 100644 (file)
@@ -12,47 +12,97 @@ include_once(__DIR__.'/../src/Wrapper.php');
 
 /* Expose as global functions the ones which are now class methods */
 
+/**
+ * @see PhpXmlRpc\Wrapper::php_2_xmlrpc_type
+ * @param string $phpType
+ * @return string
+ */
 function php_2_xmlrpc_type($phpType)
 {
     $wrapper = new PhpXmlRpc\Wrapper();
-    return $wrapper->php_2_xmlrpc_type($phpType);
+    return $wrapper->php2XmlrpcType($phpType);
 }
 
+/**
+ * @see PhpXmlRpc\Wrapper::xmlrpc_2_php_type
+ * @param string $xmlrpcType
+ * @return string
+ */
 function xmlrpc_2_php_type($xmlrpcType)
 {
     $wrapper = new PhpXmlRpc\Wrapper();
-    return $wrapper->xmlrpc_2_php_type($xmlrpcType);
+    return $wrapper->xmlrpc2PhpType($xmlrpcType);
 }
 
-/// @todo return string instead of callable
+/// @todo backwards compat: return string instead of callable
+/**
+ * @see PhpXmlRpc\Wrapper::wrap_php_function
+ * @param callable $funcName
+ * @param string $newFuncName
+ * @param array $extraOptions
+ * @return array|false
+ */
 function wrap_php_function($funcName, $newFuncName='', $extraOptions=array())
 {
     $wrapper = new PhpXmlRpc\Wrapper();
-    return $wrapper->wrap_php_function($funcName, $newFuncName, $extraOptions);
+    return $wrapper->wrapPhpFunction($funcName, $newFuncName, $extraOptions);
 }
 
-/// @todo return strings instead of callables
+/// @todo backwards compat: return strings instead of callables
+/**
+ * @see PhpXmlRpc\Wrapper::wrap_php_class
+ * @param string|object $className
+ * @param array $extraOptions
+ * @return array|false
+ */
 function wrap_php_class($className, $extraOptions=array())
 {
     $wrapper = new PhpXmlRpc\Wrapper();
-    return $wrapper->wrap_php_class($className, $extraOptions);
+    return $wrapper->wrapPhpClass($className, $extraOptions);
 }
 
-/// @todo support different calling convention
-/// @todo return string instead of callable
+/// @todo backwards compat: return string instead of callable
+/**
+ * @see PhpXmlRpc\Wrapper::wrapXmlrpcMethod
+ * @param xmlrpc_client $client
+ * @param string $methodName
+ * @param int|array $extraOptions the usage of an int as signature number is deprecated, use an option in $extraOptions
+ * @param int $timeout            deprecated, use an option in $extraOptions
+ * @param string $protocol        deprecated, use an option in $extraOptions
+ * @param string $newFuncName     deprecated, use an option in $extraOptions
+ * @return array|callable|false
+ */
 function wrap_xmlrpc_method($client, $methodName, $extraOptions=0, $timeout=0, $protocol='', $newFuncName='')
 {
+    if (!is_array($extraOptions))
+    {
+        $sigNum = $extraOptions;
+        $extraOptions = array(
+            'signum' => $sigNum,
+            'timeout' => $timeout,
+            'protocol' => $protocol,
+            'new_function_name' => $newFuncName
+        );
+    }
+
     $wrapper = new PhpXmlRpc\Wrapper();
-    return $wrapper->wrap_xmlrpc_method($client, $methodName, $extraOptions, $timeout, $protocol, $newFuncName);
+    return $wrapper->wrapXmlrpcMethod($client, $methodName, $extraOptions);
 }
 
-/// @todo return strings instead of callables
+/// @todo backwards compat: return strings instead of callables
+/**
+ * @see PhpXmlRpc\Wrapper::wrap_xmlrpc_server
+ * @param xmlrpc_client $client
+ * @param array $extraOptions
+ * @return mixed
+ */
 function wrap_xmlrpc_server($client, $extraOptions=array())
 {
     $wrapper = new PhpXmlRpc\Wrapper();
-    return $wrapper->wrap_xmlrpc_server($client, $extraOptions);
+    return $wrapper->wrapXmlrpcServer($client, $extraOptions);
 }
 
+/// @todo fix dangling usage of $this->
 /**
  * Given the necessary info, build php code that creates a new function to invoke a remote xmlrpc method.
  * Take care that no full checking of input parameters is done to ensure that valid php code is emitted.
@@ -62,9 +112,9 @@ function wrap_xmlrpc_server($client, $extraOptions=array())
  * @deprecated
  */
 function build_remote_method_wrapper_code($client, $methodName, $xmlrpcFuncName,
-                                                 $mSig, $mDesc = '', $timeout = 0, $protocol = '', $clientCopyMode = 0, $prefix = 'xmlrpc',
-                                                 $decodePhpObjects = false, $encodePhpObjects = false, $decodeFault = false,
-                                                 $faultResponse = '', $namespace = '\\PhpXmlRpc\\')
+     $mSig, $mDesc = '', $timeout = 0, $protocol = '', $clientCopyMode = 0, $prefix = 'xmlrpc',
+     $decodePhpObjects = false, $encodePhpObjects = false, $decodeFault = false,
+     $faultResponse = '', $namespace = '\\PhpXmlRpc\\')
 {
     $code = "function $xmlrpcFuncName (";
     if ($clientCopyMode < 2) {
@@ -106,14 +156,14 @@ function build_remote_method_wrapper_code($client, $methodName, $xmlrpcFuncName,
             }
         }
         $innerCode .= "\$req->addparam(\$p$i);\n";
-        $mDesc .= '* @param ' . $this->xmlrpc_2_php_type($pType) . " \$p$i\n";
+        $mDesc .= '* @param ' . xmlrpc_2_php_type($pType) . " \$p$i\n";
     }
     if ($clientCopyMode < 2) {
         $plist[] = '$debug=0';
         $mDesc .= "* @param int \$debug when 1 (or 2) will enable debugging of the underlying {$prefix} call (defaults to 0)\n";
     }
     $plist = implode(', ', $plist);
-    $mDesc .= '* @return ' . $this->xmlrpc_2_php_type($mSig[0]) . " (or an {$namespace}Response obj instance if call fails)\n*/\n";
+    $mDesc .= '* @return ' . xmlrpc_2_php_type($mSig[0]) . " (or an {$namespace}Response obj instance if call fails)\n*/\n";
 
     $innerCode .= "\$res = \${$this_}client->send(\$req, $timeout, '$protocol');\n";
     if ($decodeFault) {