- * Given a user-defined PHP function, create a PHP 'wrapper' function that can
- * be exposed as xmlrpc method from an xmlrpc_server object and called from remote
- * clients (as well as its corresponding signature info).
- *
- * Since php is a typeless language, to infer types of input and output parameters,
- * it relies on parsing the javadoc-style comment block associated with the given
- * function. Usage of xmlrpc native types (such as datetime.dateTime.iso8601 and base64)
- * in the @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 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)
- * - 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 php 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)
- * - usage of javadoc @param tags using param names in a different order from the
- * function prototype is not considered valid (to be fixed?)
- *
- * Note that since rel. 2.0RC3 the preferred method to have the server call 'standard'
- * php functions (ie. functions not expecting a single xmlrpcmsg obj as parameter)
- * is by making use of the functions_parameters_type class member.
- *
- * @param string $funcname the name of the PHP user function to be exposed as xmlrpc method; array($obj, 'methodname') and array('class', 'methodname') are ok too
- * @param string $newfuncname (optional) name for function to be created
- * @param array $extra_options (optional) array of options for conversion. valid values include:
- * bool return_source when true, php code w. function definition will be returned, not evaluated
- * bool encode_php_objs let php objects be sent to server using the 'improved' xmlrpc notation, so server can deserialize them as php objects
- * bool decode_php_objs --- WARNING !!! possible security hazard. only use it with trusted servers ---
- * bool suppress_warnings remove from produced xml any runtime warnings due to the php function being invoked
- * @return false on error, or an array containing the name of the new php function,
- * its signature and docs, to be used in the server dispatch map
- *
- * @todo decide how to deal with params passed by ref: bomb out or allow?
- * @todo finish using javadoc info to build method sig if all params are named but out of order
- * @todo add a check for params of 'resource' type
- * @todo add some trigger_errors / error_log when returning false?
- * @todo what to do when the PHP function returns NULL? we are currently returning an empty string value...
- * @todo add an option to suppress php warnings in invocation of user function, similar to server debug level 3?
- * @todo if $newfuncname is empty, we could use create_user_func instead of eval, as it is possibly faster
- * @todo add a verbatim_object_copy parameter to allow avoiding the same obj instance?
- */
- public function wrap_php_function($funcname, $newfuncname='', $extra_options=array())
+ * Given a user-defined PHP function, create a PHP 'wrapper' function that can
+ * be exposed as xmlrpc method from an xmlrpc server object and called from remote
+ * clients (as well as its corresponding signature info).
+ *
+ * Since php is a typeless language, to infer types of input and output parameters,
+ * it relies on parsing the javadoc-style comment block associated with the given
+ * function. Usage of xmlrpc native types (such as datetime.dateTime.iso8601 and base64)
+ * in the '@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 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)
+ * - functions returning php objects will generate special structs in 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 php 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)
+ *
+ * Note that since rel. 2.0RC3 the preferred method to have the server call 'standard'
+ * php functions (ie. functions not expecting a single Request obj as parameter)
+ * is by making use of the functions_parameters_type class member.
+ *
+ * @param callable $callable the PHP user function to be exposed as xmlrpc method/ a closure, function name, array($obj, 'methodname') or array('class', 'methodname') are ok
+ * @param string $newFuncName (optional) name for function to be created. Used only when return_source in $extraOptions is true
+ * @param array $extraOptions (optional) array of options for conversion. valid values include:
+ * - bool return_source when true, php code w. function definition will be returned, instead of a closure
+ * - bool encode_php_objs let php objects be sent to server using the 'improved' xmlrpc notation, so server can deserialize them as php objects
+ * - bool decode_php_objs --- WARNING !!! possible security hazard. only use it with trusted servers ---
+ * - bool suppress_warnings remove from produced xml any warnings generated at runtime by the php function being invoked
+ *
+ * @return array|false false on error, or an array containing the name of the new php function,
+ * its signature and docs, to be used in the server dispatch map
+ *
+ * @todo decide how to deal with params passed by ref in function definition: bomb out or allow?
+ * @todo finish using phpdoc info to build method sig if all params are named but out of order
+ * @todo add a check for params of 'resource' type
+ * @todo add some trigger_errors / error_log when returning false?
+ * @todo what to do when the PHP function returns NULL? We are currently returning an empty string value...
+ * @todo add an option to suppress php warnings in invocation of user function, similar to server debug level 3?
+ * @todo add a verbatim_object_copy parameter to allow avoiding usage the same obj instance?
+ * @todo add an option to allow generated function to skip validation of number of parameters, as that is done by the server anyway
+ */
+ public function wrapPhpFunction($callable, $newFuncName = '', $extraOptions = array())