Skip to content

Commit

Permalink
Merge branch 'master' of github.com:gggeek/phpxmlrpc
Browse files Browse the repository at this point in the history
  • Loading branch information
gggeek committed Jun 26, 2016
2 parents ac1be9e + 5fc0c8c commit b0a92b1
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 13 deletions.
7 changes: 4 additions & 3 deletions doc/manual/phpxmlrpc_manual.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -220,9 +220,9 @@ If you've benefited from the effort that has been put into writing this software

===== int

The type i4 is accepted as a synonym
The type i4 and i8 are accepted as a synonym
for int when creating xmlrpcval objects. The
xml parsing code will always convert i4 to
xml parsing code will always convert i4 and i8 to
int: int is regarded
by this implementation as the canonical name for this type.

Expand Down Expand Up @@ -890,14 +890,15 @@ $xmlrpcerruser800The minimum value for errors reported by user
reserved for library usage.


==== $xmlrpcI4, $xmlrpcInt, $xmlrpcBoolean, $xmlrpcDouble, $xmlrpcString, $xmlrpcDateTime, $xmlrpcBase64, $xmlrpcArray, $xmlrpcStruct, $xmlrpcValue, $xmlrpcNull
==== $xmlrpcI4, $xmlrpcI8 $xmlrpcInt, $xmlrpcBoolean, $xmlrpcDouble, $xmlrpcString, $xmlrpcDateTime, $xmlrpcBase64, $xmlrpcArray, $xmlrpcStruct, $xmlrpcValue, $xmlrpcNull

For convenience the strings representing the XML-RPC types have
been encoded as global variables:
[source, php]
----
$xmlrpcI4="i4";
$xmlrpcI8="i8";
$xmlrpcInt="int";
$xmlrpcBoolean="boolean";
$xmlrpcDouble="double";
Expand Down
2 changes: 1 addition & 1 deletion lib/xmlrpc_wrappers.inc
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ function build_remote_method_wrapper_code($client, $methodName, $xmlrpcFuncName,
for ($i = 1; $i < $pCount; $i++) {
$plist[] = "\$p$i";
$pType = $mSig[$i];
if ($pType == 'i4' || $pType == 'int' || $pType == 'boolean' || $pType == 'double' ||
if ($pType == 'i4' || $pType == 'i8' || $pType == 'int' || $pType == 'boolean' || $pType == 'double' ||
$pType == 'string' || $pType == 'dateTime.iso8601' || $pType == 'base64' || $pType == 'null'
) {
// only build directly xmlrpc values when type is known and scalar
Expand Down
3 changes: 3 additions & 0 deletions src/Helper/XMLParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ class XMLParser
'VALUE' => array('MEMBER', 'DATA', 'PARAM', 'FAULT'),
'BOOLEAN' => array('VALUE'),
'I4' => array('VALUE'),
'I8' => array('VALUE'),
'INT' => array('VALUE'),
'STRING' => array('VALUE'),
'DOUBLE' => array('VALUE'),
Expand Down Expand Up @@ -101,6 +102,7 @@ public function xmlrpc_se($parser, $name, $attrs, $acceptSingleVals = false)
$this->_xh['php_class'] = null;
break;
case 'I4':
case 'I8':
case 'INT':
case 'STRING':
case 'BOOLEAN':
Expand Down Expand Up @@ -259,6 +261,7 @@ public function xmlrpc_ee($parser, $name, $rebuildXmlrpcvals = true)
break;
case 'BOOLEAN':
case 'I4':
case 'I8':
case 'INT':
case 'STRING':
case 'DOUBLE':
Expand Down
2 changes: 1 addition & 1 deletion src/Server.php
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,7 @@ protected function verifySignature($in, $sigs)
$pt = $p->kindOf();
}
} else {
$pt = $in[$n] == 'i4' ? 'int' : strtolower($in[$n]); // dispatch maps never use i4...
$pt = ($in[$n] == 'i4' || $in[$n] == 'i8') ? 'int' : strtolower($in[$n]); // dispatch maps never use i4...
}

// param index is $n+1, as first member of sig is return type
Expand Down
16 changes: 10 additions & 6 deletions src/Value.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
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";
Expand All @@ -23,6 +24,7 @@ class Value implements \Countable, \IteratorAggregate, \ArrayAccess

public static $xmlrpcTypes = array(
"i4" => 1,
"i8" => 1,
"int" => 1,
"boolean" => 1,
"double" => 1,
Expand Down Expand Up @@ -61,6 +63,7 @@ public function __construct($val = -1, $type = '')
$this->me['string'] = $val;
break;
case 'i4':
case 'i8':
case 'int':
case 'double':
case 'string':
Expand Down Expand Up @@ -93,7 +96,7 @@ public function __construct($val = -1, $type = '')
* 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
*/
Expand Down Expand Up @@ -249,6 +252,7 @@ protected function serializedata($typ, $val, $charsetEncoding = '')
break;
case static::$xmlrpcInt:
case static::$xmlrpcI4:
case static::$xmlrpcI8:
$rs .= "<${typ}>" . (int)$val . "</${typ}>";
break;
case static::$xmlrpcDouble:
Expand Down Expand Up @@ -403,15 +407,15 @@ public function scalarval()
/**
* 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
*/
public function scalartyp()
{
reset($this->me);
list($a,) = each($this->me);
if ($a == static::$xmlrpcI4) {
if ($a == static::$xmlrpcI4 || $a == static::$xmlrpcI8) {
$a = static::$xmlrpcInt;
}

Expand Down Expand Up @@ -524,7 +528,7 @@ public function offsetSet($offset, $value) {
}
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) {
Expand All @@ -545,7 +549,7 @@ public function offsetExists($offset) {
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;
Expand Down Expand Up @@ -584,4 +588,4 @@ public function offsetGet($offset) {
throw new \Exception("XML-RPC Value is of type 'undef' and can not be accessed using array index");
}
}
}
}
6 changes: 4 additions & 2 deletions src/Wrapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ public function php2XmlrpcType($phpType)
case 'integer':
case Value::$xmlrpcInt: // 'int'
case Value::$xmlrpcI4:
case Value::$xmlrpcI8:
return Value::$xmlrpcInt;
case Value::$xmlrpcDouble: // 'double'
return Value::$xmlrpcDouble;
Expand Down Expand Up @@ -84,6 +85,7 @@ public function xmlrpc2PhpType($xmlrpcType)
return Value::$xmlrpcString;
case 'int':
case 'i4':
case 'i8':
return 'integer';
case 'struct':
case 'array':
Expand Down Expand Up @@ -836,7 +838,7 @@ protected function buildWrapMethodClosure($client, $methodName, array $extraOpti
break;
}
$pType = $mSig[$i+1];
if ($pType == 'i4' || $pType == 'int' || $pType == 'boolean' || $pType == 'double' ||
if ($pType == 'i4' || $pType == 'i8' || $pType == 'int' || $pType == 'boolean' || $pType == 'double' ||
$pType == 'string' || $pType == 'dateTime.iso8601' || $pType == 'base64' || $pType == 'null'
) {
// by building directly xmlrpc values when type is known and scalar (instead of encode() calls),
Expand Down Expand Up @@ -925,7 +927,7 @@ public function buildWrapMethodSource($client, $methodName, array $extraOptions,
for ($i = 1; $i < $pCount; $i++) {
$plist[] = "\$p$i";
$pType = $mSig[$i];
if ($pType == 'i4' || $pType == 'int' || $pType == 'boolean' || $pType == 'double' ||
if ($pType == 'i4' || $pType == 'i8' || $pType == 'int' || $pType == 'boolean' || $pType == 'double' ||
$pType == 'string' || $pType == 'dateTime.iso8601' || $pType == 'base64' || $pType == 'null'
) {
// only build directly xmlrpc values when type is known and scalar
Expand Down

0 comments on commit b0a92b1

Please sign in to comment.