SF.net SVN: phpwiki:[11054] trunk/lib/XMLRPC

vargenau--- via phpwiki-checkins <[email protected]> Fri, 14 Jul 2023 11:16:48 +0000
Newsgroups gmane.comp.web.wiki.phpwiki.checkins
Message-ID <[email protected]>
Revision: 11054
          http://sourceforge.net/p/phpwiki/code/11054
Author:   vargenau
Date:     2023-07-14 11:16:48 +0000 (Fri, 14 Jul 2023)
Log Message:
-----------
lib/XMLRPC: PHP 7: add types for function arguments and return

Modified Paths:
--------------
    trunk/lib/XMLRPC/utils.php
    trunk/lib/XMLRPC/xmlrpc.inc
    trunk/lib/XMLRPC/xmlrpc_emu.inc
    trunk/lib/XMLRPC/xmlrpcs.inc
    trunk/lib/XMLRPC/xmlrpcs_emu.inc

Modified: trunk/lib/XMLRPC/utils.php
===================================================================
--- trunk/lib/XMLRPC/utils.php	2023-07-14 11:09:38 UTC (rev 11053)
+++ trunk/lib/XMLRPC/utils.php	2023-07-14 11:16:48 UTC (rev 11054)
@@ -42,7 +42,7 @@
 // a function to ensure the xmlrpc extension is loaded.
 // xmlrpc_epi_dir = directory where libxmlrpc.so.0 is located
 // xmlrpc_php_dir = directory where xmlrpc-epi-php.so is located
-function xu_load_extension($xmlrpc_php_dir = "")
+function xu_load_extension($xmlrpc_php_dir = ""): bool
 {
     $bSuccess = extension_loaded('xmlrpc');
     if (!$bSuccess) {
@@ -60,7 +60,7 @@
 
 /* generic function to call an http server with post method */
 function xu_query_http_post($request, $host, $uri, $port, $debug,
-                            $timeout, $user, $pass, $secure = false)
+                            $timeout, $user, $pass, $secure = false): string
 {
     $response_buf = "";
     if ($host && $uri && $port) {
@@ -124,7 +124,7 @@
     return $response_buf;
 }
 
-function xu_fault_code($code, $string)
+function xu_fault_code($code, $string): array
 {
     return array('faultCode' => $code,
         'faultString' => $string);
@@ -189,7 +189,7 @@
  *
  *                   $output_options = array('output_type' => 'php');
  */
-function xu_rpc_http_concise($params)
+function xu_rpc_http_concise($params): string
 {
     $host = $uri = $port = $method = $args = $debug = null;
     $timeout = $user = $pass = $secure = $cookies = null;
@@ -219,7 +219,7 @@
 
 /* call an xmlrpc method on a remote http server. legacy support. */
 function xu_rpc_http($method, $args, $host, $uri = "/", $port = 80, $debug = false,
-                     $timeout = 0, $user = false, $pass = false, $secure = false)
+                     $timeout = 0, $user = false, $pass = false, $secure = false): string
 {
     return xu_rpc_http_concise(
         array(
@@ -236,7 +236,7 @@
         ));
 }
 
-function xu_is_fault($arg)
+function xu_is_fault($arg): bool
 {
     // xmlrpc extension finally supports this.
     return is_array($arg) ? xmlrpc_is_fault($arg) : false;

Modified: trunk/lib/XMLRPC/xmlrpc.inc
===================================================================
--- trunk/lib/XMLRPC/xmlrpc.inc	2023-07-14 11:09:38 UTC (rev 11053)
+++ trunk/lib/XMLRPC/xmlrpc.inc	2023-07-14 11:16:48 UTC (rev 11054)
@@ -233,7 +233,7 @@
  * Until php provides functionality to translate these entities in its
  * core library, use this function.
  */
-function xmlrpc_html_entity_xlate($data = '')
+function xmlrpc_html_entity_xlate($data = ''): string
 {
     $entities = array(
         "&nbsp;" => "&#160;",
@@ -486,7 +486,7 @@
     return strtr($data, $entities);
 }
 
-function xmlrpc_encode_entitites($data)
+function xmlrpc_encode_entitites($data): string
 {
     $length = strlen($data);
     $escapeddata = "";
@@ -1077,7 +1077,7 @@
         return $resp;
     }
 
-    function multicall($msgs, $timeout = 0, $method = 'http')
+    function multicall($msgs, $timeout = 0, $method = 'http'): array
     {
         $results = false;
 
@@ -1217,7 +1217,7 @@
         return $this->val;
     }
 
-    function serialize()
+    function serialize(): string
     {
         $result = "<methodResponse>\n";
         if ($this->errno) {
@@ -1263,12 +1263,12 @@
         }
     }
 
-    function xml_header()
+    function xml_header(): string
     {
         return "<?xml version=\"1.0\"?" . ">\n<methodCall>\n";
     }
 
-    function xml_footer()
+    function xml_footer(): string
     {
         return "</methodCall>\n";
     }
@@ -1314,7 +1314,7 @@
         return $this->params[$i];
     }
 
-    function getNumParams()
+    function getNumParams(): int
     {
         return sizeof($this->params);
     }
@@ -1551,7 +1551,7 @@
         }
     }
 
-    function addScalar($val, $type = 'string')
+    function addScalar($val, $type = 'string'): int
     {
         global $xmlrpcTypes, $xmlrpcBoolean;
 
@@ -1586,7 +1586,7 @@
         return 1;
     }
 
-    function addArray($vals)
+    function addArray($vals): int
     {
         global $xmlrpcTypes;
         if ($this->mytype != 0) {
@@ -1599,7 +1599,7 @@
         return 1;
     }
 
-    function addStruct($vals)
+    function addStruct($vals): int
     {
         global $xmlrpcTypes;
         if ($this->mytype != 0) {
@@ -1624,7 +1624,7 @@
         }
     }
 
-    function kindOf()
+    function kindOf(): string
     {
         switch ($this->mytype) {
             case 3:
@@ -1641,7 +1641,7 @@
         }
     }
 
-    function serializedata($typ, $val)
+    function serializedata($typ, $val): string
     {
         $rs = '';
         global $xmlrpcTypes, $xmlrpcBase64, $xmlrpcString,
@@ -1690,12 +1690,12 @@
         return $rs;
     }
 
-    function serialize()
+    function serialize(): string
     {
         return $this->serializeval($this);
     }
 
-    function serializeval($o)
+    function serializeval($o): string
     {
         //global $xmlrpcTypes;
         $rs = '';
@@ -1719,7 +1719,7 @@
         reset($this->me['struct']);
     }
 
-    function structeach()
+    function structeach(): array
     {
         return each($this->me['struct']);
     }
@@ -1784,7 +1784,7 @@
         return $nv;
     }
 
-    function arraysize()
+    function arraysize(): int
     {
         reset($this->me);
         list($a, $b) = each($this->me);

Modified: trunk/lib/XMLRPC/xmlrpc_emu.inc
===================================================================
--- trunk/lib/XMLRPC/xmlrpc_emu.inc	2023-07-14 11:09:38 UTC (rev 11053)
+++ trunk/lib/XMLRPC/xmlrpc_emu.inc	2023-07-14 11:16:48 UTC (rev 11054)
@@ -255,7 +255,7 @@
     }
 
     // public. serialize self as xml string.
-    function serialize()
+    function serialize(): string
     {
         /* check if fault */
         if ($this->fn) {
@@ -291,13 +291,13 @@
     }
 
     // unused. xmlrpc-epi does this automagically
-    function xml_header()
+    function xml_header(): string
     {
         return "xml_header not supported";
     }
 
     // unused. not necessary
-    function xml_footer()
+    function xml_footer(): string
     {
         return "xml_footer not supported";
     }
@@ -339,7 +339,7 @@
         return $this->params[$i];
     }
 
-    function getNumParams()
+    function getNumParams(): int
     {
         return sizeof($this->params);
     }
@@ -399,7 +399,7 @@
     }
 
     // public. add a php scalar value.
-    function addScalar($val, $type = "string")
+    function addScalar($val, $type = "string"): int
     {
         global $xmlrpcTypes, $xmlrpcBoolean;
 
@@ -435,7 +435,7 @@
     }
 
     // public. add a php array
-    function addArray($vals)
+    function addArray($vals): int
     {
         global $xmlrpcTypes;
         if ($this->mytype != 0) {
@@ -449,7 +449,7 @@
     }
 
     // public. add a php keyed array as a struct.
-    function addStruct($vals)
+    function addStruct($vals): int
     {
         global $xmlrpcTypes;
         if ($this->mytype != 0) {
@@ -477,7 +477,7 @@
 
     // public. kind of value.
     // (not 1 to 1 mapping with xmlrpc types or php types)
-    function kindOf()
+    function kindOf(): string
     {
         switch ($this->mytype) {
             case 3:
@@ -495,7 +495,7 @@
     }
 
     // unused.
-    function serializedata($typ, $val)
+    function serializedata($typ, $val): string
     {
         return "serializedata not supported";
     }
@@ -529,7 +529,7 @@
     }
 
     // public. get key/val pair of next struct item.
-    function structeach()
+    function structeach(): array
     {
         return each($this->me["struct"]);
     }
@@ -562,7 +562,7 @@
     }
 
     // public. get array size
-    function arraysize()
+    function arraysize(): int
     {
         reset($this->me);
         list($a, $b) = each($this->me);

Modified: trunk/lib/XMLRPC/xmlrpcs.inc
===================================================================
--- trunk/lib/XMLRPC/xmlrpcs.inc	2023-07-14 11:09:38 UTC (rev 11053)
+++ trunk/lib/XMLRPC/xmlrpcs.inc	2023-07-14 11:16:48 UTC (rev 11054)
@@ -245,7 +245,7 @@
         }
     }
 
-    function serializeDebug()
+    function serializeDebug(): string
     {
         global $_xmlrpc_debuginfo;
         if ($_xmlrpc_debuginfo != '') {
@@ -281,7 +281,7 @@
         );
     }
 
-    function verifySignature($in, $sig)
+    function verifySignature($in, $sig): array
     {
         for ($i = 0; $i < sizeof($sig); $i++) {
             // check each possible signature in turn

Modified: trunk/lib/XMLRPC/xmlrpcs_emu.inc
===================================================================
--- trunk/lib/XMLRPC/xmlrpcs_emu.inc	2023-07-14 11:09:38 UTC (rev 11053)
+++ trunk/lib/XMLRPC/xmlrpcs_emu.inc	2023-07-14 11:16:48 UTC (rev 11054)
@@ -77,7 +77,7 @@
  * is then returned to the server, parsed, and possibly spit  *
  * out as xmlrpc.                                             *
  *************************************************************/
-function _introspection_cb($userdata)
+function _introspection_cb($userdata): string
 {
     foreach ($userdata as $name => $method) {
         if ($incr++ > 0) break;
@@ -157,7 +157,7 @@
     }
 
     // private. not really useful anymore since this is all handled by the xmlrpc-epi stuff.
-    function serializeDebug()
+    function serializeDebug(): string
     {
         global $_xmlrpc_debuginfo;
         if ($_xmlrpc_debuginfo != "")
@@ -183,7 +183,7 @@
     }
 
     // private. no equivalent in C library (yet)
-    function verifySignature($in, $sig)
+    function verifySignature($in, $sig): string
     {
         return "verifySignature not supported";
     }

This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.