return $out;
}
}
-
return $xmlrpcVal->scalarval();
+
case 'array':
$arr = array();
foreach($xmlrpcVal as $value) {
$arr[] = $this->decode($value, $options);
}
-
return $arr;
+
case 'struct':
// If user said so, try to rebuild php objects for specific struct vals.
/// @todo should we raise a warning for class not found?
foreach ($xmlrpcVal as $key => $value) {
$obj->$key = $this->decode($value, $options);
}
-
return $obj;
} else {
$arr = array();
foreach ($xmlrpcVal as $key => $value) {
$arr[$key] = $this->decode($value, $options);
}
-
return $arr;
}
+
case 'msg':
$paramCount = $xmlrpcVal->getNumParams();
$arr = array();
for ($i = 0; $i < $paramCount; $i++) {
$arr[] = $this->decode($xmlrpcVal->getParam($i), $options);
}
-
return $arr;
+
+ /// @todo throw on unsupported type
}
}
* @param mixed $phpVal the value to be converted into an xmlrpc value object
* @param array $options can include 'encode_php_objs', 'auto_dates', 'null_extension' or 'extension_api'
*
- * @return \PhpXmlrpc\Value
+ * @return Value
*/
public function encode($phpVal, $options = array())
{
* Convert the xml representation of a method response, method request or single
* xmlrpc value into the appropriate object (a.k.a. deserialize).
*
- * Q: is this a good name for this method? It does something quite different from 'decode' after all
- * (returning objects vs returns plain php values)...
+ * @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
*
* @param string $xmlVal
* @param array $options
*
- * @return mixed false on error, or an instance of either Value, Request or Response
+ * @return Value|Request|Response|false false on error, or an instance of either Value, Request or Response
*/
public function decodeXml($xmlVal, $options = array())
{
} else {
$r = new Response($v);
}
-
return $r;
+
case 'methodcall':
$req = new Request($xmlRpcParser->_xh['method']);
for ($i = 0; $i < count($xmlRpcParser->_xh['params']); $i++) {
$req->addParam($xmlRpcParser->_xh['params'][$i]);
}
-
return $req;
+
case 'value':
return $xmlRpcParser->_xh['value'];
+
case 'fault':
// EPI api emulation
$v = $xmlRpcParser->_xh['value'];
use PhpXmlRpc\PhpXmlRpc;
+/**
+ * @todo implement an interface
+ */
class Charset
{
// tables used for transcoding different charsets into us-ascii xml
/**
* This class is singleton for performance reasons.
- * @todo can't we just make $xml_iso88591_Entities a static variable instead ?
+ * @todo should we just make $xml_iso88591_Entities a static variable instead ?
*
* @return Charset
*/
throw new \Exception('Unsupported charset: ' . $charset);
}
}
-
}
/**
* Parses HTTP an http response headers and separates them from the body.
*
- * @param string $data the http response,headers and body. It will be stripped of headers
+ * @param string $data the http response, headers and body. It will be stripped of headers
* @param bool $headersProcessed when true, we assume that response inflating and dechunking has been already carried out
*
* @return array with keys 'headers' and 'cookies'
namespace PhpXmlRpc\Helper;
/**
- * @todo make constructor private to force users to go through `instance()`
+ * @todo implement an interface
+ * @todo make constructor private to force users to go through `instance()` ?
*/
class Logger
{
protected static $instance = null;
/**
- * This class is singleton, so that later we can move to DI patterns.
+ * This class can be used as singleton, so that later we can move to DI patterns.
*
* @return Logger
*/
if ($respEncoding == 'ISO-8859-1') {
$data = utf8_encode($data);
} else {
+
if (extension_loaded('mbstring')) {
$data = mb_convert_encoding($data, 'UTF-8', $respEncoding);
} else {
}
// second error check: xml well formed but not xml-rpc compliant
elseif ($xmlRpcParser->_xh['isf'] == 2) {
+ $r = new Response(0, PhpXmlRpc::$xmlrpcerr['invalid_return'],
+ PhpXmlRpc::$xmlrpcstr['invalid_return'] . ' ' . $xmlRpcParser->_xh['isf_reason']);
+
if ($this->debug) {
/// @todo echo something for user?
}
-
- $r = new Response(0, PhpXmlRpc::$xmlrpcerr['invalid_return'],
- PhpXmlRpc::$xmlrpcstr['invalid_return'] . ' ' . $xmlRpcParser->_xh['isf_reason']);
}
// third error check: parsing of the response has somehow gone boink.
- // NB: shall we omit this check, since we trust the parsing code?
+ /// @todo shall we omit this check, since we trust the parsing code?
elseif ($returnType == 'xmlrpcvals' && !is_object($xmlRpcParser->_xh['value'])) {
// something odd has happened
// and it's time to generate a client side error
public $raw_data = '';
/**
- * @param mixed $val either a Value object, a php value or the xml serialization of an xmlrpc value (a string)
+ * @param Value|string|mixed $val either a Value object, a php value or the xml serialization of an xmlrpc value (a string)
* @param integer $fCode set it to anything but 0 to create an error response. In that case, $val is discarded
* @param string $fString the error string, in case of an error response
* @param string $valType The type of $val passed in. Either 'xmlrpcvals', 'phpvals' or 'xml'. Leave empty to let
* 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.
*
- * @return array array of cookies received from the server
+ * @return array[] array of cookies received from the server
*/
public function cookies()
{
*
* When no value or type is passed in, the value is left uninitialized, and the value can be added later.
*
- * @param mixed $val if passing in an array, all array elements should be PhpXmlRpc\Value themselves
+ * @param Value[]|mixed $val if passing in an array, all array elements should be PhpXmlRpc\Value themselves
* @param string $type any valid xmlrpc type name (lowercase): i4, int, boolean, string, double, dateTime.iso8601,
* base64, array, struct, null.
* If null, 'string' is assumed.
}
}
+ /**
+ * @param string typ
+ * @param Value[]|mixed $val
+ * @param string $charsetEncoding
+ * @return string
+ */
protected function serializedata($typ, $val, $charsetEncoding = '')
{
$rs = '';
* Implements the IteratorAggregate interface
*
* @return \ArrayIterator
+ * @internal required to be public to implement an Interface
*/
public function getIterator()
{