Moodle PHP Documentation 4.1
Moodle 4.1.11 (Build: 20240610) (c8c84b4af18)
PhpXmlRpc\Encoder Class Reference

Public Member Functions

 decode ($xmlrpcVal, $options=array())
 Takes an xmlrpc value in object format and translates it into native PHP types.
 
 decodeXml ($xmlVal, $options=array())
 Convert the xml representation of a method response, method request or single xmlrpc value into the appropriate object (a.k.a.
 
 encode ($phpVal, $options=array())
 Takes native php types and encodes them into xmlrpc PHP object format.
 
 getLogger ()
 
 getParser ()
 

Static Public Member Functions

static setLogger ($logger)
 
static setParser ($parser)
 

Static Protected Attributes

static $logger
 
static $parser
 

Member Function Documentation

◆ decode()

PhpXmlRpc\Encoder::decode ( $xmlrpcVal,
$options = array() )

Takes an xmlrpc value in object format and translates it into native PHP types.

Works with xmlrpc requests objects as input, too.

Given proper options parameter, can rebuild generic php object instances (provided those have been encoded to xmlrpc format using a corresponding option in php_xmlrpc_encode()) PLEASE NOTE that rebuilding php objects involves calling their constructor function. This means that the remote communication end can decide which php code will get executed on your server, leaving the door possibly open to 'php-injection' style of attacks (provided you have some classes defined on your server that might wreak havoc if instances are built outside an appropriate context). Make sure you trust the remote server/client before enabling this!

Author
Dan Libby (dan@l.nosp@m.ibby.nosp@m..com)
Parameters
Value | Request$xmlrpcVal
array$optionsif 'decode_php_objs' is set in the options array, xmlrpc structs can be decoded into php objects; if 'dates_as_objects' is set xmlrpc datetimes are decoded as php DateTime objects
Return values
mixed

◆ decodeXml()

PhpXmlRpc\Encoder::decodeXml ( $xmlVal,
$options = array() )

Convert the xml representation of a method response, method request or single xmlrpc value into the appropriate object (a.k.a.

deserialize).

Todo
is this a good name/class for this method? It does something quite different from 'decode' after all (returning objects vs returns plain php values)... In fact it belongs rather to a Parser class
Parameters
string$xmlVal
array$options
Return values
Value|Request|Response|falsefalse on error, or an instance of either Value, Request or Response

◆ encode()

PhpXmlRpc\Encoder::encode ( $phpVal,
$options = array() )

Takes native php types and encodes them into xmlrpc PHP object format.

It will not re-encode xmlrpc value objects.

Feature creep – could support more types via optional type argument (string => datetime support has been added, ??? => base64 not yet)

If given a proper options parameter, php object instances will be encoded into 'special' xmlrpc values, that can later be decoded into php objects by calling php_xmlrpc_decode() with a corresponding option

Author
Dan Libby (dan@l.nosp@m.ibby.nosp@m..com)
Parameters
mixed$phpValthe value to be converted into an xmlrpc value object
array$optionscan include 'encode_php_objs', 'auto_dates', 'null_extension' or 'extension_api'
Return values
Value

The documentation for this class was generated from the following file: