Encoder
in package
uses
LoggerAware, ParserAware
A helper class to easily convert between Value objects and php native values.
Tags
Table of Contents
Properties
Methods
- decode() : mixed
- Takes an xml-rpc Value in object instance and translates it into native PHP types, recursively.
- decodeXml() : Value|Request|Response|false
- Convert the xml representation of a method response, method request or single xml-rpc value into the appropriate object (a.k.a. deserialize).
- encode() : Value
- Takes native php types and encodes them into xml-rpc Value objects, recursively.
- getLogger() : mixed
- getParser() : mixed
- setLogger() : void
- setParser() : void
Properties
$logger
protected
static mixed
$logger
$parser
protected
static mixed
$parser
Methods
decode()
Takes an xml-rpc Value in object instance and translates it into native PHP types, recursively.
public
decode(Value|Request $xmlrpcVal[, array<string|int, mixed> $options = array() ]) : mixed
Works with xml-rpc Request objects as input, too. Xmlrpc dateTime values will be converted to strings or DateTime objects depending on an $options parameter Supports i8 and NIL xml-rpc values without the need for specific options. Both xml-rpc arrays and structs are decoded into PHP arrays, with the exception described below: Given proper options parameter, can rebuild generic php object instances (provided those have been encoded to xml-rpc 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!
Parameters
- $xmlrpcVal : Value|Request
- $options : array<string|int, mixed> = array()
-
accepted elements:
- 'decode_php_objs': if set in the options array, xml-rpc structs can be decoded into php objects, see the details above;
- 'dates_as_objects': when set xml-rpc dateTimes are decoded as php DateTime objects
- 'extension_api': reserved for usage by phpxmlrpc-polyfill
Tags
Return values
mixed —Feature creep -- add an option to allow converting xml-rpc dateTime values to unix timestamps (integers)
decodeXml()
Convert the xml representation of a method response, method request or single xml-rpc value into the appropriate object (a.k.a. deserialize).
public
decodeXml(string $xmlVal[, array<string|int, mixed> $options = array() ]) : Value|Request|Response|false
Parameters
- $xmlVal : string
- $options : array<string|int, mixed> = array()
-
unused atm
Tags
Return values
Value|Request|Response|false —false on error, or an instance of either Value, Request or Response
encode()
Takes native php types and encodes them into xml-rpc Value objects, recursively.
public
encode(mixed $phpVal[, array<string|int, mixed> $options = array() ]) : Value
PHP strings, integers, floats and booleans have a straightforward encoding - note that integers will not be
converted to xml-rpc
Parameters
- $phpVal : mixed
-
the value to be converted into an xml-rpc value object
- $options : array<string|int, mixed> = array()
-
can include:
- 'encode_php_objs' when set, some out-of-band info will be added to the xml produced by serializing the built Value, which can later be decoced by this library to rebuild an instance of the same php object
- 'auto_dates': when set, any string which respects the xml-rpc datetime format will be converted to a dateTime Value
- 'null_extension': when set, php NULL values will be converted to an xml-rpc <NIL> (or EX:NIL) Value
- 'extension_api': reserved for usage by phpxmlrpc-polyfill
Tags
Return values
Value —Feature creep -- could support more types via optional type argument (string => datetime support has been added, ??? => base64 not yet). Also: allow auto-encoding of integers to i8 when too-big to fit into i4
getLogger()
public
getLogger() : mixed
getParser()
public
getParser() : mixed
setLogger()
public
static setLogger(mixed $logger) : void
Parameters
- $logger : mixed
setParser()
public
static setParser(mixed $parser) : void
Parameters
- $parser : mixed