Moodle PHP Documentation 4.5
Moodle 4.5dev (Build: 20240606) (d3ae1391abe)
PhpXmlRpc\Response Class Reference

Public Member Functions

 __construct ($val, $fCode=0, $fString='', $valType='', $httpResponse=null)
 
__get ($name)
 
 __isset ($name)
 
 __set ($name, $value)
 
 __unset ($name)
 
 cookies ()
 Returns an array with the cookies received from the server.
 
 faultCode ()
 Returns the error code of the response.
 
 faultString ()
 Returns the error code of the response.
 
 httpResponse ()
 Returns an array with info about the http response received from the server.
 
 serialize ($charsetEncoding='')
 Returns xml representation of the response, XML prologue not included.
 
 value ()
 Returns the value received by the server.
 
 valueType ()
 
 xml_header ($charsetEncoding='')
 

Protected Attributes

int $errno = 0
 
string $errstr = ''
 
 $httpResponse = array('headers' => array(), 'cookies' => array(), 'raw_data' => '', 'status_code' => null)
 
Value string mixed $val = 0
 
string $valtyp
 

Constructor & Destructor Documentation

◆ __construct()

PhpXmlRpc\Response::__construct ( $val,
$fCode = 0,
$fString = '',
$valType = '',
$httpResponse = null )
Parameters
Value | string | mixed$valeither a Value object, a php value or the xml serialization of an xml-rpc value (a string). Note that using anything other than a Value object wll have an impact on serialization.
integer$fCodeset it to anything but 0 to create an error response. In that case, $val is discarded
string$fStringthe error string, in case of an error response
string$valTypeThe type of $val passed in. Either 'xmlrpcvals', 'phpvals' or 'xml'. Leave empty to let the code guess the correct type by looking at $val - in which case strings are assumed to be serialized xml
array | null$httpResponsethis should be set when the response is being built out of data received from http (i.e. not when programmatically building a Response server-side). Array keys should include, if known: headers, cookies, raw_data, status_code
Todo
add check that $val / $fCode / $fString is of correct type? We could at least log a warning for fishy cases... NB: as of now we do not do it, since it might be either an xml-rpc value or a plain php val, or a complete xml chunk, depending on usage of Client\send() inside which the constructor is called.

Member Function Documentation

◆ cookies()

PhpXmlRpc\Response::cookies ( )

Returns an array with the cookies received from the server.

Array has the form: $cookiename => array ('value' => $val, $attr1 => $val1, $attr2 => $val2, ...) with attributes being e.g. 'expires', 'path', domain'. NB: cookies sent as 'expired' by the server (i.e. with an expiry date in the past) are still present in the array. It is up to the user-defined code to decide how to use the received cookies, and whether they have to be sent back with the next request to the server (using $client->setCookie) or not. The values are filled in at constructor time, and might not be set for specific debug values used.

Return values
array[]array of cookies received from the server

◆ faultCode()

PhpXmlRpc\Response::faultCode ( )

Returns the error code of the response.

Return values
integerthe error code of this response (0 for not-error responses)

◆ faultString()

PhpXmlRpc\Response::faultString ( )

Returns the error code of the response.

Return values
stringthe error string of this response ('' for not-error responses)

◆ httpResponse()

PhpXmlRpc\Response::httpResponse ( )

Returns an array with info about the http response received from the server.

The values are filled in at constructor time, and might not be set for specific debug values used.

Return values
arrayarray with keys 'headers', 'cookies', 'raw_data' and 'status_code'.

◆ serialize()

PhpXmlRpc\Response::serialize ( $charsetEncoding = '')

Returns xml representation of the response, XML prologue not included.

Sets payload and content_type properties

Parameters
string$charsetEncodingthe charset to be used for serialization. If null, US-ASCII is assumed
Return values
stringthe xml representation of the response
Exceptions
StateErrorExceptionif the response was built out of a value of an unsupported type

◆ value()

PhpXmlRpc\Response::value ( )

Returns the value received by the server.

If the Response's faultCode is non-zero then the value returned by this method should not be used (it may not even be an object).

Return values
Value|string|mixedthe Value object returned by the server. Might be an xml string or plain php value depending on the convention adopted when creating the Response

◆ valueType()

PhpXmlRpc\Response::valueType ( )
Return values
string

◆ xml_header()

PhpXmlRpc\Response::xml_header ( $charsetEncoding = '')
Parameters
string$charsetEncoding
Return values
string

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