WIP user manual; phpdoc; docs
authorgggeek <giunta.gaetano@gmail.com>
Mon, 2 Jan 2023 16:26:39 +0000 (16:26 +0000)
committergggeek <giunta.gaetano@gmail.com>
Mon, 2 Jan 2023 16:26:39 +0000 (16:26 +0000)
16 files changed:
NEWS.md
demo/client/agesort.php
demo/client/wrap.php
doc/manual/phpxmlrpc_manual.adoc
src/Client.php
src/Encoder.php
src/Helper/Charset.php
src/Helper/Date.php
src/Helper/Http.php
src/Helper/Logger.php
src/Helper/XMLParser.php
src/Request.php
src/Response.php
src/Server.php
src/Value.php
src/Wrapper.php

diff --git a/NEWS.md b/NEWS.md
index 3aee819..e744d7f 100644 (file)
--- a/NEWS.md
+++ b/NEWS.md
@@ -3,6 +3,12 @@
 * improved: added a pre-push git hook script, to avoid pushing tagged versions with inconsistent version tags in code.
   To install it, execute `composer run-script setup-git-hooks`
 
+* improved: updated the user's manual to be inline with the version4 API and all modern coding practices.
+  The manual is now bundled in the default distribution tarball, and is easily viewable as html provided you can
+  serve it using a webserver.
+
+* fixed: the value for error 'no_http2' has been switched from 15 to 19 to avoid a collision
+
 
 ## XML-RPC for PHP version 4.9.3 - 2022-12-20
 
index c3384c3..3e747d9 100644 (file)
@@ -11,6 +11,7 @@ output('<html lang="en">
 ');
 
 $inAr = array("Dave" => 24, "Edd" => 45, "Joe" => 37, "Fred" => 27);
+
 output("This is the input data:<br/><pre>");
 foreach ($inAr as $key => $val) {
     output($key . ", " . $val . "\n");
index 84ffdb8..a97e168 100644 (file)
@@ -2,9 +2,9 @@
 require_once __DIR__ . "/_prepend.php";
 
 output('<html lang="en">
-<head><title>xmlrpc - Webservice wrappper demo</title></head>
+<head><title>xmlrpc - Webservice wrapper demo</title></head>
 <body>
-<h1>Webservice wrappper demo</h1>
+<h1>Webservice wrapper demo</h1>
 
 <h2>Wrap methods exposed by server into php functions</h2>
 
index 6a7ad0e..e0768ac 100644 (file)
@@ -26,11 +26,11 @@ tests/*:: the test suite for the library, written using PhpUnit, and the configu
 == A foreword [[foreword]]
 
 You might be surprised by some API design choices made by this library. In order to understand that, please keep
-in mind that this started out as a bare framework, a long time ago, when Exceptions and the DateTime class did not exist,
-and PHP best practices were quite different from current ones. While many "nice bits" have been put in over time,
-__backwards compatibility has always taken precedence__ over API cleanups.
+in mind that this started out as a bare framework around the time of PHP 3, when Exceptions and the DateTime class did
+not exist, and PHP best practices were remarkably different from current ones. While many "nice bits" have been put in
+over time, __backwards compatibility has always taken precedence__ over API cleanups.
 
-In no particular order, this is a list of some of the things developers might find perplexing.
+In no particular order, this is partial list of things some developers might find perplexing.
 
 Extensions to the XMLRPC protocol, such as support for the `<NIL>` tag, have to be manually enabled before usage.
 
@@ -48,7 +48,7 @@ use the `PhpXmlRpc\Helper\Date` class to do the encoding and decoding for you.
 
 Most class members have "public" access, even those only meant for internal usage.
 
-There are a lot of static class variables which should be treated as if they were constants.
+There are a lot of static class variables which are meant be treated as if they were constants.
 
 Usage of Exceptions is almost non-existent.
 
@@ -59,9 +59,9 @@ A mix of snake_case and CamelCase naming is used.
 
 === Type conversion [[types]]
 
-A big part the job of this library is to convert between the data types supported by PHP (null, bool, int, float, string,
-array, object, callable, resource), and the value types supported by XMLRPC (int, boolean, string, double, dateTime.iso8601,
-base64, struct, array).
+A big part the job of this library is to convert between the data types supported by PHP (`null`, `bool`, `int`, `float`,
+`string`, `array`, `object`, `callable`, `resource`), and the value types supported by XMLRPC (`int`, `boolean`, `string`,
+`double`, `dateTime.iso8601`, `base64`, `struct`, `array`).
 
 The conversion process can be mostly automated or fully manual. It is up to the single developer to decide the best
 approach to take for his/her application.
@@ -78,7 +78,7 @@ The constructor is the normal way to create a Value. The constructor can take th
     Value new Value(Value[] $arrayVal, string $arrayTyp)
 
 The first constructor creates an empty value, which must be altered using the methods `addScalar()`, `addArray()` or
-`addStruct()` before it can be used.
+`addStruct()` before it can be used further.
 
 The second constructor creates a string scalar value.
 
@@ -156,8 +156,8 @@ $myStruct = new Value(
 
 ==== Manual type conversion: XMLRPC to PHP
 
-For Value objects of scalar type, the php value can be obtained via the `scalarval()` method. For base64 values, The
-returned value will be decoded transparently. __For dateTime values the php native value will be the string representation
+For Value objects of scalar type, the php primitive value can be obtained via the `scalarval()` method. For base64 values,
+the returned value will be decoded transparently. __NB: for dateTime values the php value will be the string representation
 by default.__
 
 Value objects of type struct and array support the `Countable`, `IteratorAggregate` and `ArrayAccess` interfaces, meaning
@@ -174,7 +174,7 @@ if (count($structValue)) {
 }
 ----
 
-As you can see, the elements of the array are Value objects themselves, ie. there is no recursive decoding happening.
+As you can see, the elements of the array are Value objects themselves, i.e. there is no recursive decoding happening.
 
 ==== Automatic type conversion: PHP to XMLRPC
 
@@ -197,7 +197,8 @@ $myStruct = new Encoder()->encode([
 ]);
 ----
 
-See the phpdoc documentation for `PhpXmlRpc\Encoder::encode` for the full details of the encoding process.
+See the http://gggeek.github.io/phpxmlrpc/doc-4/api/classes/PhpXmlRpc-Encoder.html#method_encode[phpdoc documentation]
+for `PhpXmlRpc\Encoder::encode` for the full details of the encoding process.
 
 ==== Automatic type conversion: XMLRPC to PHP
 
@@ -224,10 +225,13 @@ Note that when using automatic conversion this way, all information about the or
 impossible to tell apart an `i4` from an `i8` value, or to know if a php string had been encoded as xmlrpc string or as
 base64.
 
+See the http://gggeek.github.io/phpxmlrpc/doc-4/api/classes/PhpXmlRpc-Encoder.html#method_encode[phpdoc documentation]
+for `PhpXmlRpc\Encoder::decode` for the full details of the decoding process.
+
 ==== Notes on types
 
 ===== int
-...TODO VERIFY...
+@TODO VERIFY...
 The xml parsing code will always convert "i4" to "int": int is regarded by this implementation as the canonical name for this type.
 
 The type i8 on the other hand is considered as a separate type. Note that the library will never output integers as 'i8'
@@ -236,7 +240,7 @@ on its own, even when php is compiled in 64-bit mode.
 ===== base64
 
 Base 64 encoding is performed transparently to the caller when using this type. Decoding is also transparent.
-Therefore, you ought to consider it as a "binary" data type, for use when you want to pass data that is not 7-bit clean.
+Therefore, you ought to consider it as a "binary" data type, for use when you want to pass data that is not XML-safe.
 
 ===== boolean
 
@@ -247,37 +251,39 @@ values (including the empty string) are converted to `false`.
 
 When serializing strings, characters '<', '>', ''', '"', '&', are encoded using their entity reference as '\&lt;', '\&gt;',
 '\&apos;', '\&quot;' and '\&amp;'. All other characters outside the ASCII range are encoded using their unicode character
-reference representation (e.g. '&#200' for 'é'). The XML-RPC spec recommends only encoding '<' and '&', but this implementation
-goes further, for reasons explained by the http://www.w3.org/TR/REC-xml#syntax[XML 1.0 recommendation]. In particular,
-using character reference representation has the advantage of producing XML that is valid independently of the charset
-encoding assumed.
+reference representation (e.g. '\&#200;' for 'é'). The XML-RPC spec recommends only encoding '<' and '&', but this
+implementation goes further, for reasons explained by the http://www.w3.org/TR/REC-xml#syntax[XML 1.0 recommendation].
+In particular, using character reference representation has the advantage of producing XML that is valid independently of
+the charset encoding assumed.
 
 Note that, despite what the specification states, string values should not be used to encode binary data, as control
 characters (such as f.e. characters nr. 0 to 8) are never allowed in XML, even when encoded as character references.
 
-...TODO mention how to avoid the encoding of non-ascii, as it has perfs implications for chinese/japanese...
+@TODO mention how to avoid the encoding of non-ascii, as it has perfs implications for chinese/japanese...
 
 ===== dateTime
 
 When manually creating Value objects representing an xmlrpc dateTime.iso8601, php integers, strings and DateTimes can be
-used as source values. In such case, the original value will be returned when calling `+$value->scalarval();+`.
+used as source values. For those, the original value will be returned when calling `+$value->scalarval();+`.
 
 When Value objects are created by the library by parsing some received XML text, all Value objects representing an xmlrpc
-dateTime.iso8601 value will give return the string representation of the date when calling `+$value->scalarval();+`.
-Datetime conversion can't be reliably done in a transparent manner as the XML-RPC specification explicitly forbids passing
-of timezone specifiers in ISO8601 format dates. You can, however, use the `PhpXmlRpc\Helper\Date` class to decode the string into
-a unix timestamp, or use the `PhpXmlRpc\Encoder::decode` method with the 'dates_as_objects' option to get back a php
-DateTime (in which case the conversion is done using the `strtotime` function, which uses the timezone set in php.ini).
+dateTime.iso8601 value will return the string representation of the date when calling `+$value->scalarval();+`.
+
+Datetime conversion can't be safely done in a transparent manner as the XML-RPC specification explicitly forbids passing
+of timezone specifiers in ISO8601 format dates. You can, however, use the `PhpXmlRpc\Helper\Date` class to decode the date
+string into a unix timestamp, or use the `PhpXmlRpc\Encoder::decode` method with the 'dates_as_objects' option to get
+back a php DateTime (in which case the conversion is done using the `strtotime` function, which uses the timezone set in
+php.ini).
 
 ===== null
 
 There is no support for encoding `null` values in the XML-RPC spec, but at least a couple of extensions (and many
-toolkits) do support it. Before using `null` values in your messages, make sure that the responding party accepts
+toolkits) do support it. Before using `null` values in your messages, make sure that the remote party accepts
 them, and uses the same encoding convention.
 
 To allow reception of messages containing `<NIL/>` or `<EX:NIL/>` elements, set
 
-    PhpXmlRpc\PhpXmlRpc\$xmlrpc_null_extension = true;
+    PhpXmlRpc\PhpXmlRpc::$xmlrpc_null_extension = true;
 
 somewhere in your code before the messages are received.
 
@@ -285,7 +291,7 @@ To allow sending of messages containing `<NIL/>` elements, simply create Value o
 2nd argument in the constructor. If you'd rather have those null Values be serialized as `<EX:NIL/>` instead of `<NIL/>`,
 please set
 
-    PhpXmlRpc\PhpXmlRpc\$xmlrpc_null_apache_encoding = true;
+    PhpXmlRpc\PhpXmlRpc::$xmlrpc_null_apache_encoding = true;
 
 somewhere in your code before the values are serialized.
 
@@ -304,11 +310,11 @@ Here are a couple of usage examples of the first form:
 ----
 use PhpXmlRpc\Client;
 
-$client = new Client("http://phpxmlrpc.sourceforge.net/server.php");
+$client = new Client("https://phpxmlrpc.sourceforge.net/server.php");
 $another_client = new Client("https://james:bond@secret.service.com:443/xmlrpcserver?agent=007");
 ----
 
-...TODO TEST...
+@TODO TEST...
 Note that 'http11', '...', 'http2' and 'h2c' can be used as valid alternatives to 'http' and 'https' in the provided url.
 
 The second syntax does not allow to express a username and password to be used for basic HTTP authorization as in the
@@ -327,16 +333,102 @@ $client = new Client("/RPC2", "betty.userland.com", 80);
 The `$server_port` parameter is optional, and if omitted will default to '80' when using HTTP and '443' when using HTTPS or HTTP2.
 
 The `$transport` parameter is optional, and if omitted will default to 'http'. Allowed values are either 'http', 'https',
-'http11', 'http2' or 'h2c'. Its value can be overridden with every call to the `send()` method. See the <<send>> method below
-for more details about the meaning of the different values.
+'http11', 'http2' or 'h2c'. Its value can be overridden with every call to the `send()` method. See the
+http://gggeek.github.io/phpxmlrpc/doc-4/api/classes/PhpXmlRpc-Client.html#method_send[phpdoc documentation] for the send
+method for more details about the meaning of the different values.
 
 ==== Sending requests
 
-...TODO...
+The Client's `send` method takes a `PhpmlRpc\Request` object as first argument, and always returns a `PhpmlRpc\Response`
+one, even in case of errors communicating with the server.
+
+[source, php]
+----
+use PhpXmlRpc\Client;
+use PhpXmlRpc\Request;
+use PhpXmlRpc\Value;
+
+$stateNo = (int)$_POST["stateno"];
+$req = new Request('examples.getStateName', array(new Value($stateNo, Value::$xmlrpcInt)));
+$client = new Client("https://phpxmlrpc.sourceforge.net/server.php");
+$resp = $client->send($req);
+if (!$resp->faultCode()) {
+    $v = $resp->value();
+    print "State number $stateNo is " . htmlentities($v->scalarval()) . "<BR>";
+    print "<HR>I got this xml back<BR><PRE>" . htmlentities($resp->serialize()) . "</PRE><HR>\n";
+} else {
+    print "Fault <BR>";
+    print "Code: " . htmlentities($resp->faultCode()) . "<BR>" . "Reason: '" . htmlentities($resp->faultString()) . "'<BR>";
+}
+----
+
+==== Automatic decoding of the response's value
+
+By default, the Response object's `value()` method will return a Value object, leaving it to the developer to unbox it
+further into php primitive types. In the spirit of making the conversion between the xmlrpc types and php native types
+as simple as possible, it is possible to make the Client object return directly the decoded data by setting a value to
+the `$client->return_type` property:
+
+[source, php]
+----
+use PhpXmlRpc\Client;
+use PhpXmlRpc\Helper\XMLParser;
+use PhpXmlRpc\Request;
+use PhpXmlRpc\Value;
+
+$stateNo = (int)$_POST["stateno"];
+$req = new Request('examples.getStateName', array(new Value($stateNo, Value::$xmlrpcInt)));
+$client = new Client("https://phpxmlrpc.sourceforge.net/server.php");
+$client->return_type = XMLParser::RETURN_PHP;
+$resp = $client->send($req);
+if (!$resp->faultCode()) {
+    $v = $resp->value();
+    print "State number $stateNo is " . htmlentities($v) . "<BR>"; // no need to call `scalarval` here
+    print "<HR>I got this xml back<BR><PRE>" . htmlentities($resp->serialize()) . "</PRE><HR>\n";
+} else {
+    print "Fault <BR>";
+    print "Code: " . htmlentities($resp->faultCode()) . "<BR>" . "Reason: '" . htmlentities($resp->faultString()) . "'<BR>";
+}
+----
+
+This style of making calls will result in reduced memory and cpu usage, and be slightly faster. It is recommended for
+scenarios where the expected responses are huge, or every little bit of optimization is required.
+
+Please note that, just as with the `PhpXmlRpc\Encoder::decode` method, this will make it impossible to tell apart
+values which were sent over the wire as strings from values which were base64. On the other hand, unlike that method,
+at the moment it is not possible to make use of any options to tweak the decoding process.
+
+==== Troubleshooting failed calls
+
+To ease troubleshooting problems related to the underlying communication layer, such as authentication failures,
+character set encoding snafus, compression problems, invalid xml, etc..., the Client class can dump to the screen a
+detailed log of the HTTP request sent and response received. It can be enabled by calling the `setDebug` method with
+values `1` or `2`.
+
+It is also possible to analyze the different parts of the HTTP response received by making use of the
+`PhpXmlRpc\Response::httpResponse` method.
 
 ==== Modifying the client's behaviour
 
-...TODO...
+A wide range of options can be set to the client to manage the details of the HTTP communication layer, including
+authentication (Basic, Digest, NTLM), SSL certificates, proxies, cookies, compression of the requests, usage of keepalives
+for consecutive calls, the accepted response compression, charset encoding used for the requests and the user-agent string.
+
+See the http://gggeek.github.io/phpxmlrpc/doc-4/api/classes/PhpXmlRpc-Client.html[phpdoc documentation] for details on
+all of those.
+
+===== cURL vs socket calls
+
+Please note that, depending on the HTTP protocol version used and the options set to the client, the client will
+transparently switch between using a socket-based HTTP implementation and a cURL based implementation. If needed, you
+can make use of the `setUseCurl` method to force or disable usage of the cURL based implementation.
+
+When using cURL as the underlying transport, it is possible to set directly into the client any of the cURL options
+available in your php installation, via the `setCurlOptions` method.
+
+==== Sending multiple calls
+
+@TODO...
 
 === Server [[server]]
 
@@ -345,16 +437,17 @@ does all the work. Here's a minimal example:
 
 [source, php]
 ----
+use PhpXmlRpc\Request;
 use PhpXmlRpc\Response;
 use PhpXmlRpc\Server;
 
-function foo($xmlrpc_request) {
+function foo(Request $xmlrpc_request) {
     ...
     return new Response($some_xmlrpc_val);
 }
 
 class Bar {
-    public static function fooBar($xmlrpc_request) {
+    public static function fooBar(Request $xmlrpc_request) {
         ...
         return new Response($some_xmlrpc_val);
     }
@@ -369,60 +462,7 @@ $s = new Server(
 ----
 
 This performs everything you need to do with a server. The single constructor argument is an associative array
-from xmlrpc method names to php function names. The incoming request is parsed and dispatched to the relevant php
-function, which is responsible for returning a `Response` object, that will be serialized back to the caller.
-
-==== Method handler functions
-
-Both php functions and class methods can be registered as xmlrpc method handlers.
-
-The synopsis of a method handler function is:
-
-    Response $resp = function(Request $req)
-
-No text should be echoed 'to screen' by the handler function, or it will break the xml response sent back to the client.
-This applies also to error and warning messages that PHP prints to screen unless the appropriate parameters have been
-set in the `php.ini` file. Another way to prevent echoing of errors inside the response and facilitate debugging is to use
-the server's `SetDebug` method with debug level 3 (see ...). Exceptions thrown during execution of handler functions are
-caught by default and a XML-RPC error response is generated instead. This behaviour can be fine-tuned by usage of the
-`exception_handling` member variable (see ...).
-
-Note that if you implement a method with a name prefixed by `system.` the handler function will be invoked by the
-server with two parameters, the first being the server itself and the second being the Request object.
-
-The same php function can be registered as handler of multiple xmlrpc methods.
-
-Here is a more detailed example of what the handler function foo may do:
-
-[source, php]
-----
-use PhpXmlRpc\PhpXmlRpc;
-use PhpXmlRpc\Response;
-use PhpXmlRpc\Value;
-
-function foo ($xmlrpcreq)
-{
-    $meth = $xmlrpcreq->method(); // retrieve method name
-    $par = $xmlrpcreq->getParam(0); // retrieve value of first parameter - assumes at least one param received
-    $val = $par->scalarval(); // decode value of first parameter - assumes it is a scalar value
-
-    ...
-
-    if ($err) {
-        // this is an error condition
-        return new Response(
-            0,
-            PhpXmlRpc::$xmlrpcerruser + 1, // user error 1
-            "There's a problem, Captain"
-        );
-    } else {
-        // this is a successful value being returned
-        return new Response(new Value("All's fine!", "string"));
-    }
-}
-----
-
-See __server.php__ in this distribution for more examples of how to do this.
+from xmlrpc method names to php callables.
 
 ==== The dispatch map
 
@@ -435,7 +475,7 @@ members:
 
 * `function` - this entry is mandatory. It must be a callable: either a name of a function in the global scope which
   services the XML-RPC method, an array containing an instance of an object and a method name, or an array containing
-  a class name and a static method name (for static class methods the 'class::method' syntax is also supported).
+  a class name and a static method name (for static class methods the '$class::$method' syntax is also supported).
 
 * `signature` - this entry is an array containing the possible signatures (see <<signatures>>) for the method. If this
   entry is present then the server will check that the correct number and type of parameters have been sent for this
@@ -450,19 +490,20 @@ members:
 
 * `parameters_type` - this entry can be used when the server is working in 'xmlrpcvals' mode (see ...) to define one
   or more entries in the dispatch map as being functions that follow the 'phpvals' calling convention. The only useful
-  value is currently the string `phpvals`.
+  value is currently the string 'phpvals'.
 
-Look at the __server.php__ example in the distribution to see what a dispatch map looks like.
+Methods `system.listMethods`, `system.methodHelp`, `system.methodSignature` and `system.multicall` are already defined
+by the server, and should not be reimplemented (see ... Reserved Methods below).
 
 ==== Method signatures [[signatures]]
 
 A signature is a description of a method's return type and its parameter types. A method may have more than one
 signature.
 
-Within a server's dispatch map, each method has an array of possible signatures. Each signature is an array of types.
-The first entry is the return type. For instance, the method
+Within a server's dispatch map, each method has an array of possible signatures. Each signature is an array, with the
+first element being the return type, and the others being the types of the parameters. For instance, the method
 
-[source, php]
+[source]
 ----
 string examples.getStateName(int)
 ----
@@ -485,12 +526,12 @@ use PhpXmlRpc\Value;
 
 $findstate_sig = array(array(Value::$xmlrpcString, Value::$xmlrpcInt));
 
-$findstate_doc = 'When passed an integer between 1 and 51 returns the name of a US state, where the integer is the index
-    of that state name in an alphabetic order.';
+$findstate_doc = 'When passed an integer between 1 and 51 returns the name of a US state, where the integer is the index' .
+    'of that state name in an alphabetic order.';
 
-$s = new Server(array(
+$srv = new Server(array(
     "examples.getStateName" => array(
-        "function" => "findstate",
+        "function" => "...",
         "signature" => $findstate_sig,
         "docstring" => $findstate_doc
     )
@@ -501,8 +542,8 @@ Note that method signatures do not allow to check nested parameters, e.g. the nu
 a struct param cannot be validated.
 
 If a method that you want to expose has a definite number of parameters, but each of those parameters could reasonably
-be of multiple types, the array of acceptable signatures will easily grow into a combinatorial explosion. To avoid such
-a situation, the lib defines the class var `Value::$xmlrpcValue`, which can be used in method signatures as a placeholder
+be of multiple types, the list of acceptable signatures will easily grow into a combinatorial explosion. To avoid such
+a situation, the lib defines the class property `Value::$xmlrpcValue`, which can be used in method signatures as a placeholder
 for 'any xmlrpc type':
 
 [source, php]
@@ -514,17 +555,136 @@ $echoback_sig = array(array(Value::$xmlrpcValue, Value::$xmlrpcValue));
 
 $findstate_doc = 'Echoes back to the client the received value, regardless of its type';
 
-$s = new Server(array(
+$srv = new Server(array(
     "echoBack" => array(
-        "function" => "echoback",
+        "function" => "...",
         "signature" => $echoback_sig, // this sig guarantees that the method handler will be called with one and only one parameter
         "docstring" => $echoback_doc
     )
 ));
 ----
 
-Methods `system.listMethods`, `system.methodHelp`, `system.methodSignature` and `system.multicall` are already defined
-by the server, and should not be reimplemented (see Reserved Methods below).
+==== Method handler functions
+
+The same php function can be registered as handler of multiple xmlrpc methods.
+
+No text should be echoed 'to screen' by the handler function, or it will break the xml response sent back to the client.
+This applies also to error and warning messages that PHP prints to screen unless the appropriate settings have been
+set in `php.ini`, namely `display_errors`. Another way to prevent echoing of errors inside the response and
+facilitate debugging is to use the server's `SetDebug` method with debug level 3 (see ...).
+
+Exceptions thrown during execution of handler functions are caught by default and an XML-RPC error response is generated
+instead. This behaviour can be fine-tuned by usage of the `$exception_handling` server property (see ...).
+
+===== Manual type conversion
+
+In this mode of operation, the incoming request is parsed into a `Request` object and dispatched to the relevant php
+function, which is responsible for returning a `Response` object, that will be serialized back to the caller.
+The synopsis of a method handler function is thus:
+
+    Response $resp = function(Request $req)
+
+Note that if you implement a method with a name prefixed by `system.` the handler function will be invoked by the
+server with two parameters, the first being the server itself and the second being the Request object.
+
+Here is a more detailed example of what a handler function "foo" might do:
+
+[source, php]
+----
+use PhpXmlRpc\PhpXmlRpc;
+use PhpXmlRpc\Response;
+use PhpXmlRpc\Value;
+
+function foo ($xmlrpcreq)
+{
+    $meth = $xmlrpcreq->method(); // retrieve method name
+    $par = $xmlrpcreq->getParam(0); // retrieve value of first parameter - assumes at least one param received
+    $val = $par->scalarval(); // decode value of first parameter - assumes it is a scalar value
+
+    ...
+
+    if ($err) {
+        // this is an error condition
+        return new Response(
+            null,
+            PhpXmlRpc::$xmlrpcerruser + 1, // user error 1
+            "There's a problem, Captain"
+        );
+    } else {
+        // this is a successful value being returned
+        return new Response(new Value("All's fine!"));
+    }
+}
+----
+
+===== Automatic type conversion
+
+In the same spirit of simplification that inspired the Client's `$return_type` property, a similar property
+is available within the server class: `$functions_parameters_type`. When set to the string 'phpvals', the functions
+registered in the server dispatch map will be called with plain php values as parameters, instead of a single Request
+instance parameter. The return value of those functions is expected to be a plain php value, too. An example is worth a
+thousand words:
+
+[source, php]
+----
+use PhpXmlRpc\PhpXmlRpc;
+use PhpXmlRpc\Server;
+use PhpXmlRpc\Value;
+
+function foo($usr_id, $out_lang='en')
+{
+    ...
+
+    if ($someErrorCondition)
+        throw new \Exception('DOH!', PhpXmlRpc::$xmlrpcerruser+1);
+    else
+        return array(
+            'name' => 'Joe',
+            'age' => 27,
+            'picture' => new Value(file_get_contents($picOfTheGuy), 'base64'), // it is possible to mix php values and Value objects!
+        );
+}
+
+$srv = new Server(
+    array(
+        "examples.myFunc" => array(
+            "function" => "foo",
+            "signature" => array(
+                array(Value::$xmlrpcStruct, Value::$xmlrpcInt),
+                array(Value::$xmlrpcStruct, Value::$xmlrpcInt, $xmlrpcString)
+            )
+        )
+    ),
+    false
+);
+$srv->functions_parameters_type = 'phpvals';
+$srv->exception_handling = 1;
+$srv->service();
+----
+
+There are a few things to keep in mind when using this calling convention:
+
+* to return an xmlrpc error, the method handler function must return an instance of Response. The only other way for the
+  server to know when an error response should be served to the client is to throw an exception and set the server's
+  `exception_handling` member var to 1 (as shown above);
+
+* to return a base64 value, the method handler function must encode it on its own, creating an instance of a Value
+  object;
+
+* to fine-tune the encoding to xmlrpc types of the method handler's result, you can use the Server's
+  `$phpvals_encoding_options` property
+
+* the method handler function cannot determine the name of the xmlrpc method it is serving, unlike manual-conversion
+  handler functions that can retrieve it from the Request object;
+
+* when receiving nested parameters, the method handler function has no way to distinguish a php string that was sent as
+  base64 value from one that was sent as a string value;
+
+* this has a direct consequence on the support of `system.multicall`: a method whose signature contains datetime or base64
+  values will not be available to multicall calls;
+
+* last but not least, the direct parsing of xml to php values is faster than using xmlrpcvals, and allows the library
+  to handle much bigger messages without allocating all available server memory or smashing PHP recursive call stack.
 
 ==== Delaying the server response
 
@@ -548,7 +708,7 @@ the client, but also return the response object. This permits further manipulati
 combination with output buffering.
 
 To prevent the server from sending HTTP headers back to the client, you can pass a second parameter with a value of
-`TRUE` to the service method (the first parameter being the payload of the incoming request; it can be left empty to
+`TRUE` to the `service` method (the first parameter being the payload of the incoming request; it can be left empty to
 use automatically the HTTP POST body). In this case, the response payload will be returned instead of the response object.
 
 Xmlrpc requests retrieved by other means than HTTP POST bodies can also be processed. For example:
@@ -557,32 +717,32 @@ Xmlrpc requests retrieved by other means than HTTP POST bodies can also be proce
 ----
 use PhpXmlRpc\Server;
 
-$s = new Server(); // not passing a dispatch map prevents automatic servicing of request
+$srv = new Server(); // not passing a dispatch map prevents automatic servicing of request
 
 // ... some code that does other stuff here, including setting dispatch map into server object
 
-$resp = $s->service($xmlrpc_request_body, true); // parse a variable instead of POST body, retrieve response payload
+$resp = $srv->service($xmlrpc_request_body, true); // parse a variable instead of POST body, retrieve response payload
 
 // ... some code that does other stuff with xml response $resp here
 ----
 
-==== Modifying the server behaviour
+==== Modifying the server's behaviour
 
-A couple of methods / class variables are available to modify the behaviour of the server. The only way to take
+A couple of methods / class properties are available to modify the behaviour of the server. The only way to take
 advantage of their existence is by usage of a delayed server response (see above).
 
 ===== setDebug()
 
 This function controls weather the server is going to echo debugging messages back to the client as comments in response
 body. Valid values: 0,1,2,3, with 1 being the default. At level 0, no debug info is returned to the client. At level 2,
-the complete client request is added to the response, as part of the xml
-comments. At level 3, a new PHP error handler is set when executing user functions exposed as server methods, and all
-non-fatal errors are trapped and added as comments into the response.
+the complete client request is added to the response, as part of the xml comments. At level 3, a new PHP error handler
+is set when executing user functions exposed as server methods, and all non-fatal errors are trapped and added as comments
+into the response.
 
 ===== $allow_system_funcs
 
-Default_value: `TRUE`. When set to `FALSE`, disables support for `System.xxx` functions in the server. It might be useful e.g.
-if you do not wish the server to respond to requests to `System.ListMethods`.
+Default_value: `TRUE`. When set to `FALSE`, disables support for `System.xxx` functions in the server. It might be useful
+e.g. if you do not wish the server to respond to requests to `System.ListMethods`.
 
 ===== $compress_response
 
@@ -590,31 +750,46 @@ When set to `TRUE`, enables the server to take advantage of HTTP compression, ot
 transparently compressed, but only when an xmlrpc-client declares its support for compression in the HTTP headers of the
 request.
 
-Note that the ZLIB php extension must be installed for this to work. If it is, compress_response will default to TRUE.
+Note that the ZLIB php extension must be installed for this to work. If it is, `$compress_response` will default to TRUE.
 
 ===== $exception_handling
 
-This variable controls the behaviour of the server when an exception is thrown by a method handler php function. Valid
+This property controls the behaviour of the server when an exception is thrown by a method handler php function. Valid
 values: 0,1,2, with 0 being the default. At level 0, the server catches the exception and returns an 'internal error'
 xmlrpc response; at 1 it catches the exception and returns an xmlrpc response with the error code and error message
-corresponding to the exception that was thrown; at 2 = the exception is floated to the upper layers in the code.
+corresponding to the exception that was thrown; at 2, the exception is floated to the upper layers in the code.
 
 ===== $response_charset_encoding
 
-Charset encoding to be used for response (only affects string values).
+Charset encoding to be used for responses (only affects string values).
 
 If it can, the server will convert the generated response from internal_encoding to the intended one.
 
 Valid values are: a supported xml encoding (only `UTF-8` and `ISO-8859-1` at present, unless mbstring is enabled), `null`
 (leave charset unspecified in response and convert output stream to US_ASCII), `default` (use xmlrpc library default as
-specified in ...TODO..., convert output stream if needed), or `auto` (use client-specified charset encoding or same as
+specified in @TODO..., convert output stream if needed), or `auto` (use client-specified charset encoding or same as
 request if request headers do not specify it (unless request is US-ASCII: then use library default anyway).
 
-==== Fault reporting
+==== Troubleshooting server's method handlers
+
+A tried-and-true way to debug a piece of php code is to add a `var_dump()` call, followed by `die()`, at the exact place
+where one thinks things are going wrong. However, doing so in functions registered as xmlrpc method handlers is not as
+handy as it is for web pages: for a start a valid xmlrpc request is required to trigger execution of the code, which forces
+usage of an xmlrpc client instead of a plain browser; then, the xmlrpc client in use might lack the capability of displaying
+the received payload if it is not valid xmlrpc xml.
+
+In order to overcome this issue, two helper methods are available in the Server class: `error_occurred($message)` and
+`debugmsg($message)`. The given messages will be added as xml comments, using base64 encoding to avoid breaking xml,
+into the server's responses, provided the server's debug level has been set to at least 1 for debug messages and 2 for
+error messages. The xmlrpc client provided with this library can handle the specific format used by those xml comments,
+and will display their decoded value when it also has been set to use an appropriate debug level.
 
-Fault codes for your servers should start at the value indicated by the variable `PhpXmlRpc::$xmlrpcerruser` + 1.
+=== Fault reporting
 
-Standard errors returned by the server include:
+In order to avoid conflict with error codes used by the library, fault codes used by your servers' method handlers should
+start at the value indicated by the variable `PhpXmlRpc::$xmlrpcerruser` + 1.
+
+Standard errors returned by the library include:
 
 `1` Unknown method:: Returned if the server was asked to dispatch a method it didn't know about
 
@@ -640,75 +815,18 @@ Standard errors returned by the server include:
 `8` CURL error:: This error is generated by the client when trying to send a request with HTTPS and the HTTPS
     communication fails.
 
-`9-14` multicall errors:: These errors are generated by the server when something fails inside a system.multicall request.
-
-`100-` XML parse errors:: Returns 100 plus the XML parser error code for the fault that occurred. The faultString returned
-    explains where the parse error was in the incoming XML stream.
-
-==== 'New style' servers
-
-In the same spirit of simplification that inspired the `Client::$return_type` class variable, a new class variable
-has been added to the server class: `$functions_parameters_type`. When set to `phpvals`, the functions registered in the
-server dispatch map will be called with plain php values as parameters, instead of a single Request instance parameter.
-The return value of those functions is expected to be a plain php value, too. An example is worth a thousand words:
-
-[source, php]
-----
-use PhpXmlRpc\Response;
-use PhpXmlRpc\Server;
-use PhpXmlRpc\Value;
-
-function foo($usr_id, $out_lang='en')
-{
-    global $xmlrpcerruser;
-
-    ...
-
-    if ($someErrorCondition)
-        return new Response(0, $xmlrpcerruser+1, 'DOH!');
-    else
-        return array(
-            'name' => 'Joe',
-            'age' => 27,
-            'picture' => new Value(file_get_contents($picOfTheGuy), 'base64')
-        );
-}
-
-$s = new Server(
-    array(
-        "examples.myFunc" => array(
-            "function" => "foo",
-            "signature" => array(
-                array($xmlrpcString, $xmlrpcInt),
-                array($xmlrpcString, $xmlrpcInt, $xmlrpcString)
-            )
-        )
-    ),
-false);
-$s->functions_parameters_type = 'phpvals';
-$s->service();
-----
-
-There are a few things to keep in mind when using this simplified syntax:
-
-to return an xmlrpc error, the method handler function must return an instance of Response. The only other way for the
-server to know when an error response should be served to the client is to throw an exception and set the server's
-`exception_handling` member var to 1;
+`9-14, 18` multicall errors:: These errors are generated by the server when something fails inside a system.multicall request.
 
-to return a base64 value, the method handler function must encode it on its own, creating an instance of a Value
-object;
+`15` Invalid request payload:: ...
 
-the method handler function cannot determine the name of the xmlrpc method it is serving, unlike standard handler
-functions that can retrieve it from the Request object;
+`16` No CURL support compiled in:: ...
 
-when receiving nested parameters, the method handler function has no way to distinguish a php string that was sent as
-base64 value from one that was sent as a string value;
+`17` Internal server error:: ...
 
-this has a direct consequence on the support of `system.multicall`: a method whose signature contains datetime or base64
-values will not be available to multicall calls;
+`19` No HTTP/2 support compiled in:: ...
 
-last but not least, the direct parsing of xml to php values is much faster than using xmlrpcvals, and allows the library
-to handle much bigger messages without allocating all available server memory or smashing PHP recursive call stack.
+`100-` XML parse errors:: Returns 100 plus the XML parser error code for the fault that occurred. The faultString returned
+    explains where the parse error was in the incoming XML stream.
 
 === Reserved methods [[reserved]]
 
@@ -719,12 +837,12 @@ All methods starting with __system.__ are considered reserved by the server. PHP
 special methods, detailed in this chapter.
 
 Note that all server objects will automatically respond to clients querying these methods, unless the property
-`allow_system_funcs` has been set to false before calling the `service()` method. This might pose a security risk
+`$allow_system_funcs` has been set to false before calling the `service()` method. This might pose a security risk
 if the server is exposed to public access, e.g. on the internet.
 
 ==== system.getCapabilities
 
-...
+@TODO...
 
 ==== system.listMethods
 
@@ -760,7 +878,7 @@ if ($v->kindOf() != "array") {
 }
 ----
 
-See the __introspect.php__ demo included in this distribution for an example of using this method.
+See the __demo/client/introspect.php__ demo included in this distribution for an example of using this method.
 
 ==== system.methodHelp [[sysmethhelp]]
 
@@ -779,44 +897,13 @@ member of type string and a `params` member of type array, and corresponds to th
 It returns a response of type array, with each value of the array being either an error struct (containing the `faultCode`
 and `faultString` members) or the successful response value of the corresponding single method call.
 
-=== Static class variables [[globalvars]]
-
-Many static variables are defined in the `PhpxmlRpc\PhpXmlRpc` and other classes. Some of those are meant to be used as
-constants (and modifying their value might cause unpredictable behaviour), while some others can be modified in your
-php scripts to alter the behaviour of the xml-rpc client and server.
-
-==== "Constant" variables
+=== Global configuration [[globalvars]]
 
-===== $xmlrpcerruser
+Many static variables are defined in the `PhpxmlRpc\PhpXmlRpc` class and other classes. Some of those are meant to be
+used as constants (and modifying their value might cause unpredictable behaviour), while some others can be modified in
+your php scripts to alter the behaviour of either the xml-rpc client and server.
 
-    PhpxmlRpc\PhpXmlRpc::$xmlrpcerruser = 800
-
-The minimum value for errors reported by user implemented XML-RPC servers. Error numbers lower than that are reserved
-for library usage.
-
-===== $xmlrpcI4, $xmlrpcI8 $xmlrpcInt, $xmlrpcBoolean, $xmlrpcDouble, $xmlrpcString, $xmlrpcDateTime, $xmlrpcBase64, $xmlrpcArray, $xmlrpcStruct, $xmlrpcValue, $xmlrpcNull
-
-For convenience the strings representing the XML-RPC types have been encoded as static class variables of `PhpxmlRpc\Value`:
-
-[source, php]
-----
-Value::$xmlrpcI4 = "i4";
-Value::$xmlrpcI8 = "i8";
-Value::$xmlrpcInt = "int";
-Value::$xmlrpcBoolean = "boolean";
-Value::$xmlrpcDouble = "double";
-Value::$xmlrpcString = "string";
-Value::$xmlrpcDateTime = "dateTime.iso8601";
-Value::$xmlrpcBase64 = "base64";
-Value::$xmlrpcArray = "array";
-Value::$xmlrpcStruct = "struct";
-Value::$xmlrpcValue = "undefined";
-Value::$xmlrpcNull = "null";
-----
-
-==== Variables whose value can be modified
-
-===== xmlrpc_defencoding [[xmlrpc-defencoding]]
+==== $xmlrpc_defencoding [[xmlrpc-defencoding]]
 
     PhpxmlRpc\PhpXmlRpc::$xmlrpc_defencoding = "UTF8"
 
@@ -830,28 +917,28 @@ Note that the appropriate RFC actually mandates that XML received over HTTP with
 treated as US-ASCII, but many servers and clients 'in the wild' violate the standard, and assume the default encoding is
 UTF-8.
 
-====xmlrpc_internalencoding
+==== $xmlrpc_internalencoding
 
     PhpxmlRpc\PhpXmlRpc::$xmlrpc_internalencoding = "UTF-8"
 
 This variable defines the character set encoding that the library uses to transparently encode into valid XML the
 xml-rpc values created by the user and to re-encode the received xml-rpc values when it passes them to the PHP application.
-It only affects xml-rpc values of string type. It is a separate value from xmlrpc_defencoding, allowing e.g. to send/receive
+It only affects xml-rpc values of string type. It is a separate value from `$xmlrpc_defencoding`, allowing e.g. to send/receive
 xml messages encoded on-the-wire in US-ASCII and process them as UTF-8. It defaults to the character set used internally
 by PHP (unless you are running an MBString-enabled installation), so you should change it only in special situations, if
 e.g. the string values exchanged in the xml-rpc messages are directly inserted into / fetched from a database
-configured to return non-UTF8 encoded strings to PHP. Example
-usage:
+configured to return non-UTF8 encoded strings to PHP. Example usage (quite contrived, as the asciidoc manual is saved
+in UTF-8):
 
 [source, php]
 ----
 use PhpXmlRpc\Value;
 
-PhpxmlRpc\PhpXmlRpc::$xmlrpc_internalencoding = 'UTF-8'; // this has to be set after the inclusion above
-$v = new Value('κόÏ\83με'); // This xmlrpc value will be correctly serialized as the greek word 'kosme'
+PhpxmlRpc\PhpXmlRpc::$xmlrpc_internalencoding = 'ISO-8859-1';
+$v = new Value(utf8_decode('Hélène')); // This xmlrpc value will be correctly serialized as the french name
 ----
 
-===== xmlrpcName
+===== $xmlrpcName
 
     PhpxmlRpc\PhpXmlRpc::$xmlrpcName = "XML-RPC for PHP"
 
@@ -859,7 +946,7 @@ The string representation of the name of the XML-RPC for PHP library. It is used
 HTTP header that is sent with every request to the server. You can change its value if you need to customize the User-Agent
 string.
 
-===== xmlrpcVersion
+===== $xmlrpcVersion
 
     PhpxmlRpc\PhpXmlRpc::$xmlrpcVersion = "4.9.3"
 
@@ -867,7 +954,7 @@ The string representation of the version number of the XML-RPC for PHP library i
 building the User-Agent HTTP header that is sent with every request to the server. You can change its value if you need
 to customize the User-Agent string.
 
-===== xmlrpc_null_extension
+===== $xmlrpc_null_extension
 
     PhpxmlRpc\PhpXmlRpc::$xmlrpc_null_extension = FALSE
 
@@ -875,16 +962,16 @@ When set to `TRUE`, the lib will enable support for the `<NIL/>` (and `<EX:NIL/>
 the standard proposed here. This means that `<NIL>` and `<EX:NIL/>` tags received will be parsed as valid
 xmlrpc, and the corresponding xmlrpcvals will return "null" for scalarTyp().
 
-===== xmlrpc_null_apache_encoding
+===== $xmlrpc_null_apache_encoding
 
     PhpxmlRpc\PhpXmlRpc::$$xmlrpc_null_apache_encoding = FALSE
 
 When set to `TRUE`, php NULL values encoded into Value objects will get serialized using the `<EX:NIL/>` tag instead of
 `<NIL/>`. Please note that both forms are always accepted as input regardless of the value of this variable.
 
-=== Helper functions [[helpers]]
+=== Helper classes [[helpers]]
 
-XML-RPC for PHP contains some helper functions which you can use to make processing of XML-RPC requests easier.
+XML-RPC for PHP contains some helper classes which you can use to make processing of XML-RPC requests easier.
 
 ==== Date functions
 
@@ -927,7 +1014,7 @@ to be in the UTC timezone, and thus the result is also UTC: otherwise, the timez
 and you receive a local timestamp.
 
 [[arrayuse]]
-...TODO MERGE...
+@TODO MERGE...
 ==== Easy use with nested PHP values
 
 Dan Libby was kind enough to contribute two helper functions that make it easier to translate to and from PHP values.
@@ -997,7 +1084,7 @@ struct-type xmlrpcvals, excepted for php values that are already
 instances of the Value class or descendants thereof, which will
 not be further encoded. Note that there's no support for encoding php
 values into base-64 values. Encoding of date-times is optionally
-carried on on php strings with the correct format.
+carried-on on php strings with the correct format.
 
 The options parameter is optional. If specified, it must consist of an array of options to be enabled in the
 encoding process. At the moment the only valid options are encode_php_objs, `null_extension` and auto_dates.
@@ -1050,26 +1137,19 @@ if ($val) echo 'Found a value of type '.$val->kindOf(); else echo 'Found invalid
 
 ==== Automatic conversion of php functions into xmlrpc methods (and vice versa)
 
-For the extremely lazy coder, helper functions have been added
-that allow to convert a php function into an xmlrpc method, and a
-remotely exposed xmlrpc method into a local php function - or a set of
-methods into a php class. Note that these comes with many caveat.
+For the extremely lazy coder, helper functions have been added that allow to convert a php function into an xmlrpc method,
+and a remotely exposed xmlrpc method into a local php function - or a set of xmlrpc methods into a php class. Note that these come with many caveat.
 
 [[wrap_xmlrpc_method]]
 ===== wrap_xmlrpc_method
 
     string wrap_xmlrpc_method($client, $methodname, $extra_options)
-    string wrap_xmlrpc_method($client, $methodname, $signum, $timeout, $protocol, $funcname)
-
-Given an xmlrpc server and a method name, creates a php wrapper
-function that will call the remote method and return results using
-native php types for both params and results. The generated php
-function will return an Response object for failed xmlrpc
-calls.
 
-The second syntax is deprecated, and is listed here only for backward compatibility.
+Given an xmlrpc server and a method name, creates a php wrapper function that will call the remote method and return
+results using native php types for both params and results. The generated php function will return a Response object
+for failed xmlrpc calls.
 
-The server must support the system.methodSignature xmlrpc method call for this function to work.
+The server must support the `system.methodSignature` xmlrpc method call for this function to work.
 
 The client param must be a valid Client object, previously created with the address of the target xmlrpc server, and to
 which the preferred communication options have been set.
@@ -1095,7 +1175,7 @@ set, instances of php objects later passed as parameters to the newly
 created function will receive a 'special' treatment that allows the
 server to rebuild them as php objects instead of simple arrays. Note
 that this entails using a "slightly augmented" version of the xmlrpc
-protocol (ie. using element attributes), which might not be understood
+protocol (i.e. using element attributes), which might not be understood
 by xmlrpc servers implemented using other libraries.
 
 If the `decode_php_objs` optional parameter is
@@ -1135,7 +1215,7 @@ Example usage:
 ----
 use PhpXmlRpc\Client;
 
-$c = new Client('http://phpxmlrpc.sourceforge.net/server.php');
+$c = new Client('https://phpxmlrpc.sourceforge.net/server.php');
 
 $function = wrap_xmlrpc_method($client, 'examples.getStateName');
 
@@ -1161,21 +1241,19 @@ else {
 Given a user-defined PHP function, create a PHP 'wrapper' function that can be exposed as xmlrpc method from a Server
 object and called from remote clients, and return the appropriate definition to be added to a server's dispatch map.
 
-The optional $wrapper_function_name specifies the name that will be used for the auto-generated function.
+The optional `$wrapper_function_name` specifies the name that will be used for the auto-generated function.
 
-Since php is a typeless language, to infer types of input and output parameters, it relies on parsing the javadoc-style
+Since php is a typeless language, to infer types of input and output parameters, it relies on parsing the phpdoc-style
 comment block associated with the given function. Usage of xmlrpc native types (such as datetime.dateTime.iso8601 and
 base64) in the docblock @param tag is also allowed, if you need the php function to receive/send data in that particular
-format (note that base64 encoding/decoding is transparently carried out by the lib, while datetime vals are passed
+format (note that base64 encoding/decoding is transparently carried out by the lib, while datetime values are passed
 around as strings).
 
-Known limitations: only works for user-defined functions, not for PHP internal functions (reflection
-does not support retrieving number/type of params for those); the
-wrapped php function will not be able to programmatically return an
+Known limitations: only works for user-defined functions, not for PHP internal functions (reflection does not support
+retrieving number/type of params for those); the wrapped php function will not be able to programmatically return an
 xmlrpc error response.
 
-If the `return_source` optional parameter is
-set, the function will return the php source code to build the wrapper
+If the `return_source` optional parameter is set, the function will return the php source code to build the wrapper
 function, instead of evaluating it (useful to save the code and use it
 later in a stand-alone xmlrpc server). It will be in the stored in the
 `source` member of the returned array.
@@ -1185,31 +1263,20 @@ is set, any runtime warning generated while processing the
 user-defined php function will be caught and not be printed in the
 generated xml response.
 
-If the extra_options array contains the
-`encode_php_objs` value, wrapped functions returning
-php objects will generate "special" xmlrpc responses: when the xmlrpc
-decoding of those responses is carried out by this same lib, using the
-appropriate param in php_xmlrpc_decode(), the objects will be
-rebuilt.
+If the extra_options array contains the `encode_php_objs` value, wrapped functions returning php objects will generate
+"special" xmlrpc responses: when the xmlrpc decoding of those responses is carried out by this same lib, using the
+appropriate param in php_xmlrpc_decode(), the objects will be rebuilt.
 
-In short: php objects can be serialized, too (except for their
-resource members), using this function. Other libs might choke on the
-very same xml that will be generated in this case (i.e. it has a
-nonstandard attribute on struct element tags)
+In short: php objects can be serialized, too (except for their resource members), using this function. Other libs might
+choke on the very same xml that will be generated in this case (i.e. it has a nonstandard attribute on struct element tags)
 
-If the `decode_php_objs` optional parameter is
-set, instances of php objects that have been appropriately encoded by
-the client using a coordinate option will be deserialized and passed
-to the user function as php objects instead of simple arrays (the same
-class definition should be present server side and client
-side).
+If the `decode_php_objs` optional parameter is set, instances of php objects that have been appropriately encoded by
+the client using a coordinate option will be deserialized and passed to the user function as php objects instead of simple
+arrays (the same class definition should be present server side and client side).
 
-__Note that this might pose a security risk__,
-since in order to rebuild the object instances their constructor
-method has to be invoked, and this means that the remote client can
-trigger execution of unforeseen php code on the server: not really a
-code injection, but almost. Please enable this option only when you
-trust the remote clients.
+__Note that this might pose a security risk__, since in order to rebuild the object instances their constructor
+method has to be invoked, and this means that the remote client can trigger execution of unforeseen php code on the
+server: not really a code injection, but almost. Please enable this option only when you trust the remote clients.
 
 Example usage:
 
@@ -1224,7 +1291,7 @@ use PhpXmlRpc\Server;
 */
 function findstate($stateno)
 {
-    global $stateNames;
+    $stateNames = array(...);
     if (isset($stateNames[$stateno-1]))
     {
         return $stateNames[$stateno-1];
@@ -1243,59 +1310,6 @@ if ($findstate_sig)
 $srv = new Server($methods);
 ----
 
-=== Debugging aids [[debugging]]
-
-==== xmlrpc_debugmsg
-
-    void xmlrpc_debugmsg(string $debug)
-
-Sends the contents of $debugstring in XML comments in the server return payload. If a PHP client has debugging
-turned on, the user will be able to see server debug information.
-
-Use this function in your methods so you can pass back diagnostic information. It is only available from
-__xmlrpcs.inc__.
-
-=== 'Enough of xmlrpcvals!': new style library usage [[enough]]
-
-To be documented...
-
-In the meantime, see docs about Client::return_type and Server::functions_parameters_types, as well as php_xmlrpc_encode,
-php_xmlrpc_decode and php_xmlrpc_decode_xml
-
-=== Examples [[examples]]
-
-The best examples are to be found in the sample files included with the distribution. Some are included here.
-
-==== XML-RPC client: state name query [[statename]]
-
-Code to get the corresponding state name from a number (1-50) from the demo server available on SourceForge
-
-[source, php]
-----
-use PhpXmlRpc\Client;
-use PhpXmlRpc\Request;
-use PhpXmlRpc\Value;
-
-$m = new Request('examples.getStateName', array(new Value((int)$_POST["stateno"], "int")));
-$c = new Client("/server.php", "phpxmlrpc.sourceforge.net", 80);
-$r = $c->send($m);
-if (!$r->faultCode()) {
-    $v = $r->value();
-    print "State number " . htmlentities($_POST["stateno"]) . " is " .
-        htmlentities($v->scalarval()) . "<BR>";
-    print "<HR>I got this value back<BR><PRE>" .
-        htmlentities($r->serialize()) . "</PRE><HR>\n";
-} else {
-    print "Fault <BR>";
-    print "Code: " . htmlentities($r->faultCode()) . "<BR>" .
-        "Reason: '" . htmlentities($r->faultString()) . "'<BR>";
-}
-----
-
-==== Executing a multicall call
-
-To be documented...
-
 
 == Upgrading
 
@@ -1375,7 +1389,7 @@ connectivity reasons, one way to make sure that it is working as expected and ge
 is to test against the "demo" server which comes bundled with the library:
 
 - install the library using the Composer option `--prefer-install=source`, to make sure the demo files are also downloaded
-- make sure both the `/debugger` and the `/demo` folders are within your webserver's root folder, eg. run
+- make sure both the `/debugger` and the `/demo` folders are within your webserver's root folder, e.g. run
   `PHP_CLI_SERVER_WORKERS=2 php -S 127.0.0.1:8081` from the root of the phpxmlrpc library
 - access the debugger at __http://127.0.0.1:8081/debugger__ and use it with Address: __127.0.0.1__,
   Path: __/demo/server/server.php__
@@ -1384,7 +1398,7 @@ is to test against the "demo" server which comes bundled with the library:
 
 The debugger can take advantage of the JSXMLRPC library's visual editor component to allow easy mouse-driven construction
 of the payload for remote methods. To enable the extra functionality, it has have to be downloaded separately and copied
-to the debugger directory: ...TODO...
+to the debugger directory: @TODO...
 
 
 == Running tests
@@ -1414,6 +1428,8 @@ In order to have it onboard, install the library using Composer option `--prefer
 
 == Frequently Asked Questions [[qanda]]
 
+@TODO mention setting curl options directly, following http redirects...
+
 === How to send custom XML as payload of a method call
 
 Unfortunately, at the time the XML-RPC spec was designed, support for namespaces in XML was not as ubiquitous as it
@@ -1440,7 +1456,7 @@ data over socket would be much more efficient. Or even Googles' ProtoBuffer.
 
 If you really need to move a massive amount of data around, and you are crazy enough to do it using phpxmlrpc, your best
 bet is to bypass usage of the Value objects, at least in the decoding phase, and have the server (or client) object
-return to the calling function directly php values (see `Client::return_type` and `Server::functions_parameters_type`
+return to the calling function directly php values (see `Client::return_type` and `Server::functions_parameters_types`
 for more details).
 
 === My server (client) returns an error whenever the client (server) returns accented characters
@@ -1476,7 +1492,7 @@ if (!$resp->faultCode())
 ----
 
 Note that this will not be 100% accurate, since the xml generated by the response object can be different from the xml
-received, especially if there is some character set conversion involved, or such (eg. if you receive an empty string tag
+received, especially if there is some character set conversion involved, or such (e.g. if you receive an empty string tag
 as "<string/>", `serialize()` will output "<string></string>"), or if the server sent back as response something invalid (in
 which case the xml generated client side using serialize() will correspond to the error response generated
 internally by the lib).
@@ -1494,7 +1510,7 @@ if (!$resp->faultCode())
 
 Note that using this method the xml response will not be parsed at all by the library, only the http communication
 protocol will be checked. This means that xmlrpc responses sent by the server that would have generated an error
-response on the client (eg. malformed xml, responses that have faultCode set, etc...) now will not be flagged as
+response on the client (e.g. malformed xml, responses that have faultCode set, etc...) now will not be flagged as
 invalid, and you might end up saving not valid xml but random junk...
 
 === Can I use the MS Windows character set?::
@@ -1557,7 +1573,7 @@ with phpxmlrpc. The following code snippet gives an example of such integration
 [source, php]
 ----
 /*** client side ***/
-$c = new Client('http://phpxmlrpc.sourceforge.net/server.php');
+$c = new Client('https://phpxmlrpc.sourceforge.net/server.php');
 
 // tell the client to return raw xml as response value
 $c->return_type = 'xml';
index 95d64c6..bf0f14f 100644 (file)
@@ -77,8 +77,7 @@ class Client
     public $request_compression = '';
 
     /**
-     * CURL handle: used for keep-alive connections (PHP 4.3.8 up, see:
-     * http://curl.haxx.se/docs/faq.html#7.3).
+     * CURL handle: used for keep-alive
      * @internal
      */
     public $xmlrpc_curl_handle = null;
@@ -91,11 +90,11 @@ class Client
 
     /**
      * The charset encoding that will be used for serializing request sent by the client.
-     * It defaults to NULL, which means using US-ASCII and encoding all characters outside of the ASCII printable range
+     * It defaults to NULL, which means using US-ASCII and encoding all characters outside the ASCII printable range
      * using their xml character entity representation (this has the benefit that line end characters will not be mangled
      * in the transfer, a CR-LF will be preserved as well as a singe LF).
      * Valid values are 'US-ASCII', 'UTF-8' and 'ISO-8859-1'.
-     * For the fastest mode of operation, set your both your app internal encoding as well as this to UTF-8.
+     * For the fastest mode of operation, set your both your app internal encoding and this to UTF-8.
      */
     public $request_charset_encoding = '';
 
@@ -218,15 +217,15 @@ class Client
     }
 
     /**
-     * Enable/disable the echoing to screen of the xmlrpc responses received. The default is not no output anything.
+     * Enable/disable the echoing to screen of the xmlrpc responses received. The default is not to output anything.
      *
      * The debugging information at level 1 includes the raw data returned from the XML-RPC server it was querying
      * (including bot HTTP headers and the full XML payload), and the PHP value the client attempts to create to
-     * represent the value returned by the server
-     * At level2, the complete payload of the xmlrpc request is also printed, before being sent t the server.
+     * represent the value returned by the server.
+     * At level2, the complete payload of the xmlrpc request is also printed, before being sent to the server.
      *
      * This option can be very useful when debugging servers as it allows you to see exactly what the client sends and
-     * the server returns.
+     * the server returns. Never leave it enabled for production!
      *
      * @param integer $level values 0, 1 and 2 are supported (2 = echo sent msg too, before received response)
      */
@@ -489,6 +488,7 @@ class Client
      *                       request are not compatible with h2c upgrade.
      *
      * @return Response|Response[] Note that the client will always return a Response object, even if the call fails
+     *
      * @todo allow throwing exceptions instead of returning responses in case of failed calls and/or Fault responses
      * @todo refactor: we now support many options besides connection timeout and http version to use. Why only privilege those?
      */
@@ -588,6 +588,7 @@ class Client
      * @param string $proxyPassword
      * @param int $proxyAuthType
      * @param string $method
+     *
      * @return Response
      */
     protected function sendPayloadHTTP10($req, $server, $port, $timeout = 0, $username = '', $password = '',
@@ -622,6 +623,7 @@ class Client
      * @param string $key
      * @param string $keyPass
      * @param int $sslVersion
+     *
      * @return Response
      */
     protected function sendPayloadHTTPS($req, $server, $port, $timeout = 0, $username = '',  $password = '',
@@ -657,6 +659,7 @@ class Client
      * @param string $key
      * @param string $keyPass @todo not implemented yet.
      * @param int $sslVersion @todo not implemented yet. See http://php.net/manual/en/migration56.openssl.php
+     *
      * @return Response
      *
      * @todo refactor: we get many options for the call passed in, but some we use from $this. We should clean that up
@@ -879,6 +882,7 @@ class Client
      * @param string $key
      * @param string $keyPass
      * @param int $sslVersion
+     *
      * @return Response
      *
      * @todo refactor: we get many options for the call passed in, but some we use from $this. We should clean that up
@@ -1243,6 +1247,7 @@ class Client
      * @param Request[] $reqs
      * @param int $timeout
      * @param string $method
+     *
      * @return Response[]|false|mixed|Response
      */
     private function _try_multicall($reqs, $timeout, $method)
index d58e4db..a0aa496 100644 (file)
@@ -6,7 +6,8 @@ use PhpXmlRpc\Helper\Logger;
 use PhpXmlRpc\Helper\XMLParser;
 
 /**
- * A helper class to easily convert between Value objects and php native values
+ * A helper class to easily convert between Value objects and php native values.
+ *
  * @todo implement an interface
  * @todo add class constants for the options values
  */
index 820d85b..185018e 100644 (file)
@@ -27,9 +27,10 @@ class Charset
 
     /**
      * This class is singleton for performance reasons.
-     * @todo should we just make $xml_iso88591_Entities a static variable instead ?
      *
      * @return Charset
+     *
+     * @todo should we just make $xml_iso88591_Entities a static variable instead ?
      */
     public static function instance()
     {
@@ -41,7 +42,7 @@ class Charset
     }
 
     /**
-     * Force usage as singleton
+     * Force usage as singleton.
      */
     protected function __construct()
     {
@@ -49,7 +50,9 @@ class Charset
 
     /**
      * @param string $tableName
+     *
      * @throws \Exception for unsupported $tableName
+     *
      * @todo add support for cp1252 as well as latin-2 .. latin-10
      *       Optimization creep: instead of building all those tables on load, keep them ready-made php files
      *       which are not even included until needed
@@ -58,8 +61,8 @@ class Charset
      *       (though no luck when receiving them...)
      *       Note also that, apparently, while 'ISO/IEC 8859-1' has no characters defined for bytes 128 to 159,
      *       IANA ISO-8859-1 does have well-defined 'C1' control codes for those - wikipedia's page on latin-1 says:
-     *       "ISO-8859-1 is the IANA preferred name for this standard when supplemented with the C0 and C1 control codes from ISO/IEC 6429."
-     *       Check what mbstring/iconv do by default with those?
+     *       "ISO-8859-1 is the IANA preferred name for this standard when supplemented with the C0 and C1 control codes
+     *       from ISO/IEC 6429." Check what mbstring/iconv do by default with those?
      */
     protected function buildConversionTable($tableName)
     {
@@ -121,6 +124,12 @@ class Charset
      * Note that when not sending a charset encoding mime type along with http headers, we are bound by RFC 3023 to emit
      * strict us-ascii for 'text/xml' payloads (but we should review RFC 7303, which seems to have changed the rules...)
      *
+     * @param string $data
+     * @param string $srcEncoding
+     * @param string $destEncoding
+     *
+     * @return string
+     *
      * @todo do a bit of basic benchmarking (strtr vs. str_replace)
      * @todo make usage of iconv() or mb_string() where available
      * @todo support aliases for charset names, eg ASCII, LATIN1, ISO-88591 (see f.e. polyfill-iconv for a list),
@@ -128,12 +137,6 @@ class Charset
      * @todo when converting to ASCII, allow to choose whether to escape the range 0-31,127 (non-print chars) or not
      * @todo allow picking different strategies to deal w. invalid chars? eg. source in latin-1 and chars 128-159
      * @todo add support for escaping using CDATA sections? (add cdata start and end tokens, replace only ']]>' with ']]]]><![CDATA[>')
-     *
-     * @param string $data
-     * @param string $srcEncoding
-     * @param string $destEncoding
-     *
-     * @return string
      */
     public function encodeEntities($data, $srcEncoding = '', $destEncoding = '')
     {
@@ -305,13 +308,12 @@ class Charset
     }
 
     /**
-     * Used only for backwards compatibility
+     * Used only for backwards compatibility.
      * @deprecated
      *
      * @param string $charset
      *
      * @return array
-     *
      * @throws \Exception for unknown/unsupported charsets
      */
     public function getEntities($charset)
index a83bee1..12301ad 100644 (file)
@@ -35,7 +35,7 @@ class Date
     }
 
     /**
-     * Given an ISO8601 date string, return a timet in the localtime, or UTC.
+     * Given an ISO8601 date string, return a timestamp in the localtime, or UTC.
      *
      * @param string $idate
      * @param int $utc either 0 (assume date is in local time) or 1 (assume date is in UTC)
index a10816f..16c985b 100644 (file)
@@ -8,13 +8,13 @@ use PhpXmlRpc\PhpXmlRpc;
 class Http
 {
     /**
-     * Decode a string that is encoded with "chunked" transfer encoding as defined in rfc2068 par. 19.4.6
+     * Decode a string that is encoded with "chunked" transfer encoding as defined in rfc2068 par. 19.4.6.
      * Code shamelessly stolen from nusoap library by Dietrich Ayala.
+     * @internal this function will become protected in the future
      *
      * @param string $buffer the string to be decoded
      *
      * @return string
-     * @internal this function will become protected in the future
      */
     public static function decodeChunked($buffer)
     {
@@ -51,7 +51,7 @@ class Http
 
             $chunkEnd = strpos($buffer, "\r\n", $chunkStart) + 2;
             if ($chunkEnd == false) {
-                break; //just in case we got a broken connection
+                break; // just in case we got a broken connection
             }
             $temp = substr($buffer, $chunkStart, $chunkEnd - $chunkStart);
             $chunkSize = hexdec(trim($temp));
@@ -80,8 +80,7 @@ class Http
 
         // Support "web-proxy-tunnelling" connections for https through proxies
         if (preg_match('/^HTTP\/1\.[0-1] 200 Connection established/', $data)) {
-            // Look for CR/LF or simple LF as line separator,
-            // (even though it is not valid http)
+            // Look for CR/LF or simple LF as line separator (even though it is not valid http)
             $pos = strpos($data, "\r\n\r\n");
             if ($pos || is_int($pos)) {
                 $bd = $pos + 4;
@@ -95,8 +94,7 @@ class Http
                 }
             }
             if ($bd) {
-                // this filters out all http headers from proxy.
-                // maybe we could take them into account, too?
+                // this filters out all http headers from proxy. maybe we could take them into account, too?
                 $data = substr($data, $bd);
             } else {
                 Logger::instance()->errorLog('XML-RPC: ' . __METHOD__ . ': HTTPS via proxy error, tunnel connection possibly failed');
@@ -138,8 +136,7 @@ class Http
             throw new HttpException(PhpXmlRpc::$xmlrpcstr['http_error'] . ' (' . $errstr . ')', PhpXmlRpc::$xmlrpcerr['http_error'], null, $httpResponse['status_code']);
         }
 
-        // be tolerant to usage of \n instead of \r\n to separate headers and data
-        // (even though it is not valid http)
+        // be tolerant to usage of \n instead of \r\n to separate headers and data (even though it is not valid http)
         $pos = strpos($data, "\r\n\r\n");
         if ($pos || is_int($pos)) {
             $bd = $pos + 4;
@@ -162,10 +159,9 @@ class Http
             $arr = explode(':', $line, 2);
             if (count($arr) > 1) {
                 $headerName = strtolower(trim($arr[0]));
-                /// @todo some other headers (the ones that allow a CSV list of values)
-                ///       do allow many values to be passed using multiple header lines.
-                ///       We should add content to $xmlrpc->_xh['headers'][$headerName]
-                ///       instead of replacing it for those...
+                /// @todo some other headers (the ones that allow a CSV list of values) do allow many values to be
+                ///       passed using multiple header lines.
+                ///       We should add content to $xmlrpc->_xh['headers'][$headerName] instead of replacing it for those...
                 /// @todo should we drop support for rfc2965 (set-cookie2) cookies? It has been obsoleted since 2011
                 if ($headerName == 'set-cookie' || $headerName == 'set-cookie2') {
                     if ($headerName == 'set-cookie2') {
@@ -176,8 +172,7 @@ class Http
                         $cookies = array($arr[1]);
                     }
                     foreach ($cookies as $cookie) {
-                        // glue together all received cookies, using a comma to separate them
-                        // (same as php does with getallheaders())
+                        // glue together all received cookies, using a comma to separate them (same as php does with getallheaders())
                         if (isset($httpResponse['headers'][$headerName])) {
                             $httpResponse['headers'][$headerName] .= ', ' . trim($cookie);
                         } else {
@@ -225,8 +220,7 @@ class Http
             Logger::instance()->debugMessage($msg);
         }
 
-        // if CURL was used for the call, http headers have been processed,
-        // and dechunking + reinflating have been carried out
+        // if CURL was used for the call, http headers have been processed, and dechunking + reinflating have been carried out
         if (!$headersProcessed) {
 
             // Decode chunked encoding sent by http 1.1 servers
index bee7b08..9e6908b 100644 (file)
@@ -62,7 +62,7 @@ class Logger
     }
 
     /**
-     * Writes a message to the error log
+     * Writes a message to the error log.
      * @param string $message
      */
     public function errorLog($message)
index 3508aa3..06c16aa 100644 (file)
@@ -174,6 +174,7 @@ class XMLParser
     /**
      * xml parser handler function for opening element tags.
      * @internal
+     *
      * @param resource $parser
      * @param string $name
      * @param $attrs
@@ -351,6 +352,7 @@ class XMLParser
     /**
      * xml parser handler function for close element tags.
      * @internal
+     *
      * @param resource $parser
      * @param string $name
      * @param int $rebuildXmlrpcvals >1 for rebuilding xmlrpcvals, 0 for rebuilding php values, -1 for xmlrpc-extension compatibility
@@ -538,6 +540,7 @@ class XMLParser
     /**
      * Used in decoding xmlrpc requests/responses without rebuilding xmlrpc Values.
      * @internal
+     *
      * @param resource $parser
      * @param string $name
      */
@@ -549,6 +552,7 @@ class XMLParser
     /**
      * Used in decoding xmlrpc requests/responses while building xmlrpc-extension Values (plain php for all but base64 and datetime).
      * @internal
+     *
      * @param resource $parser
      * @param string $name
      */
@@ -560,6 +564,7 @@ class XMLParser
     /**
      * xml parser handler function for character data.
      * @internal
+     *
      * @param resource $parser
      * @param string $data
      */
@@ -576,9 +581,10 @@ class XMLParser
     }
 
     /**
-     * xml parser handler function for 'other stuff', ie. not char data or
-     * element start/end tag. In fact it only gets called on unknown entities...
+     * xml parser handler function for 'other stuff', ie. not char data or element start/end tag.
+     * In fact it only gets called on unknown entities...
      * @internal
+     *
      * @param $parser
      * @param string data
      */
@@ -598,7 +604,7 @@ class XMLParser
      * xml charset encoding guessing helper function.
      * Tries to determine the charset encoding of an XML chunk received over HTTP.
      * NB: according to the spec (RFC 3023), if text/xml content-type is received over HTTP without a content-type,
-     * we SHOULD assume it is strictly US-ASCII. But we try to be more tolerant of non conforming (legacy?) clients/servers,
+     * we SHOULD assume it is strictly US-ASCII. But we try to be more tolerant of non-conforming (legacy?) clients/servers,
      * which will be most probably using UTF-8 anyway...
      * In order of importance checks:
      * 1. http headers
@@ -692,9 +698,10 @@ class XMLParser
     }
 
     /**
-     * Helper function: checks if an xml chunk has a charset declaration (BOM or in the xml declaration)
+     * Helper function: checks if an xml chunk has a charset declaration (BOM or in the xml declaration).
      *
      * @param string $xmlChunk
+     *
      * @return bool
      */
     public static function hasEncoding($xmlChunk)
index c946bda..b7e0906 100644 (file)
@@ -84,7 +84,9 @@ class Request
 
     /**
      * @internal this function will become protected in the future
+     *
      * @param string $charsetEncoding
+     *
      * @return string
      */
     public function xml_header($charsetEncoding = '')
@@ -98,6 +100,7 @@ class Request
 
     /**
      * @internal this function will become protected in the future
+     *
      * @return string
      */
     public function xml_footer()
@@ -107,6 +110,7 @@ class Request
 
     /**
      * @internal this function will become protected in the future
+     *
      * @param string $charsetEncoding
      */
     public function createPayload($charsetEncoding = '')
@@ -160,7 +164,6 @@ class Request
 
     /**
      * Add a parameter to the list of parameters to be used upon method invocation.
-     *
      * Checks that $params is actually a Value object and not a plain php value.
      *
      * @param Value $param
@@ -335,7 +338,7 @@ class Request
         $xmlRpcParser = $this->getParser();
         $xmlRpcParser->parse($data, $returnType, XMLParser::ACCEPT_RESPONSE, $options);
 
-        // first error check: xml not well formed
+        // first error check: xml not well-formed
         if ($xmlRpcParser->_xh['isf'] > 2) {
 
             // BC break: in the past for some cases we used the error message: 'XML error at line 1, check URL'
@@ -349,7 +352,7 @@ class Request
                 print $xmlRpcParser->_xh['isf_reason'];
             }
         }
-        // second error check: xml well formed but not xml-rpc compliant
+        // second error check: xml well-formed but not xml-rpc compliant
         elseif ($xmlRpcParser->_xh['isf'] == 2) {
             $r = new Response(0, PhpXmlRpc::$xmlrpcerr['xml_not_compliant'],
                 PhpXmlRpc::$xmlrpcstr['xml_not_compliant'] . ' ' . $xmlRpcParser->_xh['isf_reason'], '',
@@ -390,6 +393,7 @@ class Request
 
                 if ($errNo == 0) {
                     // FAULT returned, errno needs to reflect that
+                    /// @todo we should signal somehow that the server returned a fault with code 0?
                     $errNo = -1;
                 }
 
index d42bc2d..8a3c45e 100644 (file)
@@ -145,7 +145,6 @@ class Response
      * @param string $charsetEncoding the charset to be used for serialization. If null, US-ASCII is assumed
      *
      * @return string the xml representation of the response
-     *
      * @throws \Exception
      */
     public function serialize($charsetEncoding = '')
index 587fa41..7debd2c 100644 (file)
@@ -16,9 +16,9 @@ class Server
     protected static $charsetEncoder;
 
     /**
-     * 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'
+     * 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'.
+     *
      * @todo create class constants for these
      */
     public $functions_parameters_type = 'xmlrpcvals';
@@ -210,7 +210,6 @@ class Server
      * Add a string to the debug info that will be later serialized by the server as part of the response message
      * (base64 encoded, only when debug level >= 2)
      *
-     * character set.
      * @param string $msg
      */
     public static function error_occurred($msg)
@@ -221,6 +220,8 @@ class Server
     /**
      * Return a string with the serialized representation of all debug info.
      *
+     * @internal this function will become protected in the future
+     *
      * @param string $charsetEncoding the target charset encoding for the serialization
      *
      * @return string an XML comment (or two)
@@ -253,7 +254,6 @@ class Server
      * @param bool $returnPayload When true, return the response but do not echo it or any http header
      *
      * @return Response|string the response object (usually not used by caller...) or its xml serialization
-     *
      * @throws \Exception in case the executed method does throw an exception (and depending on server configuration)
      */
     public function service($data = null, $returnPayload = false)
@@ -282,7 +282,7 @@ class Server
             $r->raw_data = $rawData;
         }
 
-        if ($this->debug > 2 && static::$_xmlrpcs_occurred_errors) {
+        if ($this->debug > 2 && static::$_xmlrpcs_occurred_errors != '') {
             $this->debugmsg("+++PROCESSING ERRORS AND WARNINGS+++\n" .
                 static::$_xmlrpcs_occurred_errors . "+++END+++");
         }
@@ -533,15 +533,14 @@ class Server
     /**
      * Parse an xml chunk containing an xmlrpc request and execute the corresponding
      * php function registered with the server.
+     * @internal this function will become protected in the future
      *
      * @param string $data the xml request
      * @param string $reqEncoding (optional) the charset encoding of the xml request
      *
      * @return Response
-     *
      * @throws \Exception in case the executed method does throw an exception (and depending on server configuration)
      *
-     * @internal this function will become protected in the future
      * @todo either rename this function or move the 'execute' part out of it...
      */
     public function parseRequest($data, $reqEncoding = '')
@@ -586,11 +585,13 @@ class Server
         if ($xmlRpcParser->_xh['isf'] > 2) {
             // (BC) we return XML error as a faultCode
             preg_match('/^XML error ([0-9]+)/', $xmlRpcParser->_xh['isf_reason'], $matches);
-            $r = new Response(0,
-                PhpXmlRpc::$xmlrpcerrxml + $matches[1],
+            $r = new Response(
+                0,
+                PhpXmlRpc::$xmlrpcerrxml + (int)$matches[1],
                 $xmlRpcParser->_xh['isf_reason']);
         } elseif ($xmlRpcParser->_xh['isf']) {
-            $r = new Response(0,
+            $r = new Response(
+                0,
                 PhpXmlRpc::$xmlrpcerr['invalid_request'],
                 PhpXmlRpc::$xmlrpcstr['invalid_request'] . ' ' . $xmlRpcParser->_xh['isf_reason']);
         } else {
@@ -753,15 +754,14 @@ class Server
                 }
                 // the return type can be either a Response object or a plain php value...
                 if (!is_a($r, '\PhpXmlRpc\Response')) {
-                    // what should we assume here about automatic encoding of datetimes
-                    // and php classes instances???
+                    // what should we assume here about automatic encoding of datetimes and php classes instances???
                     $encoder = new Encoder();
                     $r = new Response($encoder->encode($r, $this->phpvals_encoding_options));
                 }
             }
         } catch (\Exception $e) {
-            // (barring errors in the lib) an uncatched exception happened
-            // in the called function, we wrap it in a proper error-response
+            // (barring errors in the lib) an uncatched exception happened in the called function, we wrap it in a
+            // proper error-response
             switch ($this->exception_handling) {
                 case 2:
                     if ($this->debug > 2) {
@@ -804,6 +804,7 @@ class Server
 
     /**
      * @param string $charsetEncoding
+     *
      * @return string
      */
     protected function xml_header($charsetEncoding = '')
@@ -817,6 +818,7 @@ class Server
 
     /**
      * @param string $methName
+     *
      * @return bool
      */
     protected function isSyscall($methName)
@@ -877,8 +879,6 @@ class Server
         );
     }
 
-    /* Functions that implement system.XXX methods of xmlrpc servers */
-
     /**
      * @return array[]
      */
@@ -915,8 +915,11 @@ class Server
     }
 
     /**
+     * @internal handler of a system. method
+     *
      * @param Server $server
      * @param Request $req
+     *
      * @return Response
      */
     public static function _xmlrpcs_getCapabilities($server, $req = null)
@@ -926,8 +929,11 @@ class Server
     }
 
     /**
+     * @internal handler of a system. method
+     *
      * @param Server $server
      * @param Request $req if called in plain php values mode, second param is missing
+     *
      * @return Response
      */
     public static function _xmlrpcs_listMethods($server, $req = null)
@@ -944,13 +950,16 @@ class Server
     }
 
     /**
+     * @internal handler of a system. method
+     *
      * @param Server $server
      * @param Request $req
+     *
      * @return Response
      */
     public static function _xmlrpcs_methodSignature($server, $req)
     {
-        // let accept as parameter both an xmlrpc value or string
+        // let's accept as parameter either an xmlrpc value or string
         if (is_object($req)) {
             $methName = $req->getParam(0);
             $methName = $methName->scalarval();
@@ -986,13 +995,16 @@ class Server
     }
 
     /**
+     * @internal handler of a system. method
+     *
      * @param Server $server
      * @param Request $req
+     *
      * @return Response
      */
     public static function _xmlrpcs_methodHelp($server, $req)
     {
-        // let accept as parameter both an xmlrpc value or string
+        // let's accept as parameter either an xmlrpc value or string
         if (is_object($req)) {
             $methName = $req->getParam(0);
             $methName = $methName->scalarval();
@@ -1017,6 +1029,13 @@ class Server
         return $r;
     }
 
+    /**
+     * @internal this function will become protected in the future
+     *
+     * @param $err
+     *
+     * @return Value
+     */
     public static function _xmlrpcs_multicall_error($err)
     {
         if (is_string($err)) {
@@ -1034,8 +1053,11 @@ class Server
     }
 
     /**
+     * @internal this function will become protected in the future
+     *
      * @param Server $server
      * @param Value $call
+     *
      * @return Value
      */
     public static function _xmlrpcs_multicall_do_call($server, $call)
@@ -1082,8 +1104,11 @@ class Server
     }
 
     /**
+     * @internal this function will become protected in the future
+     *
      * @param Server $server
      * @param Value $call
+     *
      * @return Value
      */
     public static function _xmlrpcs_multicall_do_call_phpvals($server, $call)
@@ -1130,8 +1155,11 @@ class Server
     }
 
     /**
+     * @internal handler of a system. method
+     *
      * @param Server $server
      * @param Request|array $req
+     *
      * @return Response
      */
     public static function _xmlrpcs_multicall($server, $req)
@@ -1160,6 +1188,8 @@ class Server
      * that a PHP execution error on the server generally entails.
      *
      * NB: in fact a user defined error handler can only handle WARNING, NOTICE and USER_* errors.
+     *
+     * @internal
      */
     public static function _xmlrpcs_errorHandler($errCode, $errString, $filename = null, $lineNo = null, $context = null)
     {
@@ -1170,7 +1200,7 @@ class Server
 
         //if ($errCode != E_NOTICE && $errCode != E_WARNING && $errCode != E_USER_NOTICE && $errCode != E_USER_WARNING)
         if ($errCode != E_STRICT) {
-            \PhpXmlRpc\Server::error_occurred($errString);
+            static::error_occurred($errString);
         }
         // Try to avoid as much as possible disruption to the previous error handling
         // mechanism in place
index e210223..e8dcabf 100644 (file)
@@ -265,6 +265,7 @@ class Value implements \Countable, \IteratorAggregate, \ArrayAccess
      * @param string $typ
      * @param Value[]|mixed $val
      * @param string $charsetEncoding
+     *
      * @return string
      */
     protected function serializedata($typ, $val, $charsetEncoding = '')
@@ -536,9 +537,10 @@ class Value implements \Countable, \IteratorAggregate, \ArrayAccess
 
     /**
      * Implements the IteratorAggregate interface
+     * @internal required to be public to implement an Interface
      *
      * @return \ArrayIterator
-     * @internal required to be public to implement an Interface
+     *
      */
     #[\ReturnTypeWillChange]
     public function getIterator()
@@ -557,8 +559,10 @@ class Value implements \Countable, \IteratorAggregate, \ArrayAccess
 
     /**
      * @internal required to be public to implement an Interface
+     *
      * @param mixed $offset
      * @param mixed $value
+     *
      * @throws \Exception
      */
     #[\ReturnTypeWillChange]
@@ -604,7 +608,9 @@ class Value implements \Countable, \IteratorAggregate, \ArrayAccess
 
     /**
      * @internal required to be public to implement an Interface
+     *
      * @param mixed $offset
+     *
      * @return bool
      */
     #[\ReturnTypeWillChange]
@@ -625,7 +631,9 @@ class Value implements \Countable, \IteratorAggregate, \ArrayAccess
 
     /**
      * @internal required to be public to implement an Interface
+     *
      * @param mixed $offset
+     *
      * @throws \Exception
      */
     #[\ReturnTypeWillChange]
@@ -648,7 +656,9 @@ class Value implements \Countable, \IteratorAggregate, \ArrayAccess
 
     /**
      * @internal required to be public to implement an Interface
+     *
      * @param mixed $offset
+     *
      * @return mixed|Value|null
      * @throws \Exception
      */
index 531d526..eec2554 100644 (file)
@@ -244,6 +244,7 @@ class Wrapper
      *
      * @param callable $callable
      * @param string $plainFuncName
+     *
      * @return array|false
      */
     protected function introspectFunction($callable, $plainFuncName)
@@ -348,12 +349,12 @@ class Wrapper
     /**
      * Given the method description given by introspection, create method signature data
      *
-     * @todo support better docs with multiple types separated by pipes by creating multiple signatures
-     *       (this is questionable, as it might produce a big matrix of possible signatures with many such occurrences)
-     *
      * @param array $funcDesc as generated by self::introspectFunction()
      *
      * @return array
+     *
+     * @todo support better docs with multiple types separated by pipes by creating multiple signatures
+     *       (this is questionable, as it might produce a big matrix of possible signatures with many such occurrences)
      */
     protected function buildMethodSignatures($funcDesc)
     {
@@ -416,19 +417,22 @@ class Wrapper
 
     /**
      * Creates a closure that will execute $callable
-     * @todo validate params? In theory all validation is left to the dispatch map...
-     * @todo add support for $catchWarnings
      *
      * @param $callable
      * @param array $extraOptions
      * @param string $plainFuncName
      * @param array $funcDesc
+     *
      * @return \Closure
+     *
+     * @todo validate params? In theory all validation is left to the dispatch map...
+     * @todo add support for $catchWarnings
      */
     protected function buildWrapFunctionClosure($callable, $extraOptions, $plainFuncName, $funcDesc)
     {
         /**
          * @param Request $req
+         *
          * @return mixed
          */
         $function = function($req) use($callable, $extraOptions, $funcDesc)
@@ -487,6 +491,7 @@ class Wrapper
      * Return a name for a new function, based on $callable, insuring its uniqueness
      * @param mixed $callable a php callable, or the name of an xmlrpc method
      * @param string $newFuncName when not empty, it is used instead of the calculated version
+     *
      * @return string
      */
     protected function newFunctionName($callable, $newFuncName, $extraOptions)
@@ -528,6 +533,7 @@ class Wrapper
      * @param array $extraOptions
      * @param string $plainFuncName
      * @param array $funcDesc
+     *
      * @return string
      *
      * @todo add a nice phpdoc block in the generated source
@@ -625,6 +631,7 @@ class Wrapper
      *                            - string method_filter  a regexp used to filter methods to wrap based on their names
      *                            - string prefix         used for the names of the xmlrpc methods created.
      *                            - string replace_class_name use to completely replace the class name with the prefix in the generated method names. e.g. instead of \Some\Namespace\Class.method use prefixmethod
+     *
      * @return array|false false on failure
      */
     public function wrapPhpClass($className, $extraOptions = array())
@@ -658,6 +665,7 @@ class Wrapper
      * @param string|object $className
      * @param string $classMethod
      * @param array $extraOptions
+     *
      * @return string
      */
     protected function generateMethodNameForClassMethod($className, $classMethod, $extraOptions = array())
@@ -697,12 +705,6 @@ class Wrapper
      * An extra 'debug' param is appended to param list of xmlrpc method, useful
      * for debugging purposes.
      *
-     * @todo allow caller to give us the method signature instead of querying for it, or just say 'skip it'
-     * @todo if we can not retrieve method signature, create a php function with varargs
-     * @todo allow the created function to throw exceptions on method calls failures
-     * @todo if caller did not specify a specific sig, shall we support all of them?
-     *       It might be hard (hence slow) to match based on type and number of arguments...
-     *
      * @param Client $client an xmlrpc client set up correctly to communicate with target server
      * @param string $methodName the xmlrpc method to be mapped to a php function
      * @param array $extraOptions array of options that specify conversion details. Valid options include
@@ -718,6 +720,12 @@ class Wrapper
      *                            - int     simple_client_copy  set it to 1 to have a lightweight copy of the $client object made in the generated code (only used when return_source = true)
      *
      * @return \closure|string[]|false false on failure, closure by default and array for return_source = true
+     *
+     * @todo allow caller to give us the method signature instead of querying for it, or just say 'skip it'
+     * @todo if we can not retrieve method signature, create a php function with varargs
+     * @todo allow the created function to throw exceptions on method calls failures
+     * @todo if caller did not specify a specific sig, shall we support all of them?
+     *       It might be hard (hence slow) to match based on type and number of arguments...
      */
     public function wrapXmlrpcMethod($client, $methodName, $extraOptions = array())
     {
@@ -756,6 +764,7 @@ class Wrapper
      * @param Client $client
      * @param string $methodName
      * @param array $extraOptions
+     *
      * @return false|array
      */
     protected function retrieveMethodSignature($client, $methodName, array $extraOptions = array())
@@ -797,6 +806,7 @@ class Wrapper
      * @param Client $client
      * @param string $methodName
      * @param array $extraOptions
+     *
      * @return string in case of any error, an empty string is returned, no warnings generated
      */
     protected function retrieveMethodHelp($client, $methodName, array $extraOptions = array())
@@ -830,6 +840,7 @@ class Wrapper
      * @param string $methodName
      * @param array $extraOptions
      * @param array $mSig
+     *
      * @return \Closure
      *
      * @todo should we allow usage of parameter simple_client_copy to mean 'do not clone' in this case?
@@ -923,6 +934,7 @@ class Wrapper
      * @param string $newFuncName
      * @param array $mSig
      * @param string $mDesc
+     *
      * @return string[] keys: source, docstring
      */
     public function buildWrapMethodSource($client, $methodName, array $extraOptions, $newFuncName, $mSig, $mDesc='')