X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=src%2FValue.php;h=d48f0b8ff440fc61a8cf81cd15d23aa83019915a;hb=5fc0c8cc5cc3d0579e0e810512ca3b672e720db6;hp=c9fc61406b39afad04a1f223a7c3e0b58df0ab1a;hpb=f4978078febfc4289bb4f45db6ca3f9e6c8c4f94;p=plcapi.git diff --git a/src/Value.php b/src/Value.php index c9fc614..d48f0b8 100644 --- a/src/Value.php +++ b/src/Value.php @@ -5,11 +5,12 @@ namespace PhpXmlRpc; use PhpXmlRpc\Helper\Charset; /** - * This class enables the creation and encapsulation of values for XML-RPC. + * This class enables the creation of values for XML-RPC, by encapsulating plain php values. */ class Value implements \Countable, \IteratorAggregate, \ArrayAccess { public static $xmlrpcI4 = "i4"; + public static $xmlrpcI8 = "i8"; public static $xmlrpcInt = "int"; public static $xmlrpcBoolean = "boolean"; public static $xmlrpcDouble = "double"; @@ -23,6 +24,7 @@ class Value implements \Countable, \IteratorAggregate, \ArrayAccess public static $xmlrpcTypes = array( "i4" => 1, + "i8" => 1, "int" => 1, "boolean" => 1, "double" => 1, @@ -61,6 +63,7 @@ class Value implements \Countable, \IteratorAggregate, \ArrayAccess $this->me['string'] = $val; break; case 'i4': + case 'i8': case 'int': case 'double': case 'string': @@ -93,7 +96,7 @@ class Value implements \Countable, \IteratorAggregate, \ArrayAccess * Fails if the xmlrpc value is not an array and already initialized. * * @param mixed $val - * @param string $type allowed values: i4, int, boolean, string, double, dateTime.iso8601, base64, null. + * @param string $type allowed values: i4, i8, int, boolean, string, double, dateTime.iso8601, base64, null. * * @return int 1 or 0 on failure */ @@ -249,6 +252,7 @@ class Value implements \Countable, \IteratorAggregate, \ArrayAccess break; case static::$xmlrpcInt: case static::$xmlrpcI4: + case static::$xmlrpcI8: $rs .= "<${typ}>" . (int)$val . ""; break; case static::$xmlrpcDouble: @@ -403,7 +407,7 @@ class Value implements \Countable, \IteratorAggregate, \ArrayAccess /** * Returns the type of the xmlrpc value. * - * For integers, 'int' is always returned in place of 'i4'. + * For integers, 'int' is always returned in place of 'i4' or 'i8'. * * @return string */ @@ -411,7 +415,7 @@ class Value implements \Countable, \IteratorAggregate, \ArrayAccess { reset($this->me); list($a,) = each($this->me); - if ($a == static::$xmlrpcI4) { + if ($a == static::$xmlrpcI4 || $a == static::$xmlrpcI8) { $a = static::$xmlrpcInt; } @@ -524,7 +528,7 @@ class Value implements \Countable, \IteratorAggregate, \ArrayAccess } return; case 1: -// todo: handle i4 vs int +// todo: handle i4/i8 vs int reset($this->me); list($type,) = each($this->me); if ($type != $offset) { @@ -545,7 +549,7 @@ class Value implements \Countable, \IteratorAggregate, \ArrayAccess case 2: return isset($this->me['array'][$offset]); case 1: -// todo: handle i4 vs int +// todo: handle i4/i8 vs int return $offset == $this->scalartyp(); default: return false; @@ -584,4 +588,4 @@ class Value implements \Countable, \IteratorAggregate, \ArrayAccess throw new \Exception("XML-RPC Value is of type 'undef' and can not be accessed using array index"); } } -} \ No newline at end of file +}