|
Open Monograph Press
3.3.0
|
Public Member Functions | |
| buildWrapMethodSource ($client, $methodName, array $extraOptions, $newFuncName, $mSig, $mDesc='') | |
| php2XmlrpcType ($phpType) | |
| wrapPhpClass ($className, $extraOptions=array()) | |
| wrapPhpFunction ($callable, $newFuncName='', $extraOptions=array()) | |
| wrapXmlrpcMethod ($client, $methodName, $extraOptions=array()) | |
| wrapXmlrpcServer ($client, $extraOptions=array()) | |
| xmlrpc2PhpType ($xmlrpcType) | |
Static Public Attributes | |
| static | $objHolder = array() |
Protected Member Functions | |
| buildClientWrapperCode ($client, $verbatimClientCopy, $prefix='xmlrpc', $namespace='\\PhpXmlRpc\\') | |
| buildMethodSignatures ($funcDesc) | |
| buildWrapFunctionClosure ($callable, $extraOptions, $plainFuncName, $funcDesc) | |
| buildWrapFunctionSource ($callable, $newFuncName, $extraOptions, $plainFuncName, $funcDesc) | |
| buildWrapMethodClosure ($client, $methodName, array $extraOptions, $mSig) | |
| introspectFunction ($callable, $plainFuncName) | |
| newFunctionName ($callable, $newFuncName, $extraOptions) | |
| retrieveMethodHelp ($client, $methodName, array $extraOptions=array()) | |
| retrieveMethodSignature ($client, $methodName, array $extraOptions=array()) | |
PHP-XMLRPC "wrapper" class. Generate stubs to transparently access xmlrpc methods as php functions and vice-versa. Note: this class implements the PROXY pattern, but it is not named so to avoid confusion with http proxies.
use some better templating system for code generation?
implement method wrapping with preservation of php objs in calls
when wrapping methods without obj rebuilding, use return_type = 'phpvals' (faster)
Definition at line 19 of file Wrapper.php.
|
protected |
Given necessary info, generate php code that will build a client object just like the given one. Take care that no full checking of input parameters is done to ensure that valid php code is emitted.
| Client | $client | |
| bool | $verbatimClientCopy | when true, copy all of the state of the client, except for 'debug' and 'return_type' |
| string | $prefix | used for the return_type of the created client |
| string | $namespace |
Definition at line 1093 of file Wrapper.php.
|
protected |
Given the method description given by introspection, create method signature data
| array | $funcDesc | as generated by self::introspectFunction() |
Definition at line 331 of file Wrapper.php.
|
protected |
Creates a closure that will execute $callable
validate params? In theory all validation is left to the dispatch map...
add support for $catchWarnings
| $callable | ||
| array | $extraOptions | |
| string | $plainFuncName | |
| string | $funcDesc |
Definition at line 401 of file Wrapper.php.
|
protected |
| $callable | ||
| string | $newFuncName | |
| array | $extraOptions | |
| string | $plainFuncName | |
| array | $funcDesc |
Definition at line 504 of file Wrapper.php.
|
protected |
| Client | $client | |
| string | $methodName | |
| array | $extraOptions | |
| string | $mSig |
Definition at line 792 of file Wrapper.php.
| PhpXmlRpc\Wrapper::buildWrapMethodSource | ( | $client, | |
| $methodName, | |||
| array | $extraOptions, | ||
| $newFuncName, | |||
| $mSig, | |||
$mDesc = '' |
|||
| ) |
| Client | $client | |
| string | $methodName | |
| array | $extraOptions | |
| string | $newFuncName | |
| array | $mSig | |
| string | $mDesc |
Definition at line 883 of file Wrapper.php.
|
protected |
Introspect a php callable and its phpdoc block and extract information about its signature
| callable | $callable | |
| string | $plainFuncName |
Definition at line 222 of file Wrapper.php.
|
protected |
Return a name for a new function, based on $callable, insuring its uniqueness
| mixed | $callable | a php callable, or the name of an xmlrpc method |
| string | $newFuncName | when not empty, it is used instead of the calculated version |
Definition at line 461 of file Wrapper.php.
| PhpXmlRpc\Wrapper::php2XmlrpcType | ( | $phpType | ) |
Given a string defining a php type or phpxmlrpc type (loosely defined: strings accepted come from javadoc blocks), return corresponding phpxmlrpc type. Notes:
| string | $phpType |
Definition at line 37 of file Wrapper.php.
|
protected |
| Client | $client | |
| string | $methodName | |
| array | $extraOptions |
Definition at line 757 of file Wrapper.php.
|
protected |
Retrieves an xmlrpc method signature from a server which supports system.methodSignature
| Client | $client | |
| string | $methodName | |
| array | $extraOptions |
Definition at line 716 of file Wrapper.php.
| PhpXmlRpc\Wrapper::wrapPhpClass | ( | $className, | |
$extraOptions = array() |
|||
| ) |
Given a user-defined PHP class or php object, map its methods onto a list of PHP 'wrapper' functions that can be exposed as xmlrpc methods from an xmlrpc server object and called from remote clients (as well as their corresponding signature info).
| string | object | $className | the name of the class whose methods are to be exposed as xmlrpc methods, or an object instance of that class |
| array | $extraOptions | see the docs for wrapPhpMethod for basic options, plus
|
Definition at line 599 of file Wrapper.php.
| PhpXmlRpc\Wrapper::wrapPhpFunction | ( | $callable, | |
$newFuncName = '', |
|||
$extraOptions = 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
| 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:
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.
| 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 |
| string | $newFuncName | (optional) name for function to be created. Used only when return_source in $extraOptions is true |
| array | $extraOptions | (optional) array of options for conversion. valid values include:
|
decide how to deal with params passed by ref in function definition: bomb out or allow?
finish using phpdoc info to build method sig if all params are named but out of order
add a check for params of 'resource' type
add some trigger_errors / error_log when returning false?
what to do when the PHP function returns NULL? We are currently returning an empty string value...
add an option to suppress php warnings in invocation of user function, similar to server debug level 3?
add a verbatim_object_copy parameter to allow avoiding usage the same obj instance?
add an option to allow generated function to skip validation of number of parameters, as that is done by the server anyway
Definition at line 151 of file Wrapper.php.
| PhpXmlRpc\Wrapper::wrapXmlrpcMethod | ( | $client, | |
| $methodName, | |||
$extraOptions = array() |
|||
| ) |
Given an xmlrpc client and a method name, register a php wrapper function that will call it 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.
Known limitations:
Notes: the connection properties of the given client will be copied and reused for the connection used during the call to the generated php function. Calling the generated php function 'might' be slow: a new xmlrpc client is created on every invocation and an xmlrpc-connection opened+closed. An extra 'debug' param is appended to param list of xmlrpc method, useful for debugging purposes.
allow caller to give us the method signature instead of querying for it, or just say 'skip it'
if we can not retrieve method signature, create a php function with varargs
allow the created function to throw exceptions on method calls failures
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...
| Client | $client | an xmlrpc client set up correctly to communicate with target server |
| string | $methodName | the xmlrpc method to be mapped to a php function |
| array | $extraOptions | array of options that specify conversion details. Valid options include
|
Definition at line 676 of file Wrapper.php.
| PhpXmlRpc\Wrapper::wrapXmlrpcServer | ( | $client, | |
$extraOptions = array() |
|||
| ) |
Similar to wrapXmlrpcMethod, but will generate a php class that wraps all xmlrpc methods exposed by the remote server as own methods. For more details see wrapXmlrpcMethod.
For a slimmer alternative, see the code in demo/client/proxy.php
Note that unlike wrapXmlrpcMethod, we always have to generate php code here. It seems that php 7 will have anon classes...
| Client | $client | the client obj all set to query the desired server |
| array | $extraOptions | list of options for wrapped code. See the ones from wrapXmlrpcMethod plus
|
Definition at line 990 of file Wrapper.php.
| PhpXmlRpc\Wrapper::xmlrpc2PhpType | ( | $xmlrpcType | ) |
Given a string defining a phpxmlrpc type return the corresponding php type.
| string | $xmlrpcType |
Definition at line 79 of file Wrapper.php.
|
static |
used to hold a reference to object instances whose methods get wrapped by wrapPhpFunction(), in 'create source' mode
Definition at line 22 of file Wrapper.php.