Skip to content
This repository was archived by the owner on Apr 28, 2020. It is now read-only.

Commit f3eeab8

Browse files
author
Justin Van Dort
committed
Disable BigInteger for i8 type if machine is 64-bit
1 parent 892775f commit f3eeab8

File tree

4 files changed

+11
-5
lines changed

4 files changed

+11
-5
lines changed

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ All notable changes to this project will be documented in this file, in reverse
1010

1111
### Changed
1212

13-
- Nothing.
13+
Disables use of BigInteger for XMLRPC i8 type if host machine is 64-bit.
1414

1515
### Deprecated
1616

docs/book/client.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -133,8 +133,8 @@ XML-RPC Type | `Zend\XmlRpc\AbstractValue` Constant | `Zend\Xm
133133
---------------- | -------------------------------------------------- | --------------------------
134134
int | `Zend\XmlRpc\AbstractValue::XMLRPC_TYPE_INTEGER` | `Zend\XmlRpc\Value\Integer`
135135
i4 | `Zend\XmlRpc\AbstractValue::XMLRPC_TYPE_I4` | `Zend\XmlRpc\Value\Integer`
136-
i8 | `Zend\XmlRpc\AbstractValue::XMLRPC_TYPE_I8` | `Zend\XmlRpc\Value\BigInteger`
137-
ex:i8 | `Zend\XmlRpc\AbstractValue::XMLRPC_TYPE_APACHEI8` | `Zend\XmlRpc\Value\BigInteger`
136+
i8 | `Zend\XmlRpc\AbstractValue::XMLRPC_TYPE_I8` | `Zend\XmlRpc\Value\BigInteger` or `Zend\XmlRpc\Value\Integer` if machine is 64-bit
137+
ex:i8 | `Zend\XmlRpc\AbstractValue::XMLRPC_TYPE_APACHEI8` | `Zend\XmlRpc\Value\BigInteger` or `Zend\XmlRpc\Value\Integer` if machine is 64-bit
138138
double | `Zend\XmlRpc\AbstractValue::XMLRPC_TYPE_DOUBLE` | `Zend\XmlRpc\ValueDouble`
139139
boolean | `Zend\XmlRpc\AbstractValue::XMLRPC_TYPE_BOOLEAN` | `Zend\XmlRpc\Value\Boolean`
140140
string | `Zend\XmlRpc\AbstractValue::XMLRPC_TYPE_STRING` | `Zend\XmlRpc\Value\Text`

src/AbstractValue.php

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,11 @@ abstract class AbstractValue
4848
*/
4949
protected static $generator;
5050

51+
/**
52+
* True if BigInteger should be used for XMLRPC i8 types
53+
*/
54+
public static $USE_BIGINT_FOR_I8 = PHP_INT_SIZE < 8;
55+
5156
/**
5257
* Specify that the XML-RPC native type will be auto detected from a PHP variable type
5358
*/
@@ -193,7 +198,7 @@ public static function getXmlRpcValue($value, $type = self::AUTO_DETECT_TYPE)
193198
case self::XMLRPC_TYPE_I8:
194199
// fall through to the next case
195200
case self::XMLRPC_TYPE_APACHEI8:
196-
return new Value\BigInteger($value);
201+
return self::$USE_BIGINT_FOR_I8 ? new Value\BigInteger($value) : new Value\Integer($value);
197202

198203
case self::XMLRPC_TYPE_DOUBLE:
199204
return new Value\Double($value);
@@ -337,7 +342,7 @@ protected static function xmlStringToNativeXmlRpc($xml)
337342
case self::XMLRPC_TYPE_APACHEI8:
338343
// Fall through to the next case
339344
case self::XMLRPC_TYPE_I8:
340-
$xmlrpcValue = new Value\BigInteger($value);
345+
$xmlrpcValue = self::$USE_BIGINT_FOR_I8 ? new Value\BigInteger($value) : new Value\Integer($value);
341346
break;
342347
case self::XMLRPC_TYPE_DOUBLE:
343348
$xmlrpcValue = new Value\Double($value);

test/BigIntegerValueTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ class BigIntegerValueTest extends TestCase
2121
{
2222
public function setUp()
2323
{
24+
AbstractValue::$USE_BIGINT_FOR_I8 = true;
2425
if (extension_loaded('gmp')) {
2526
$this->markTestSkipped('gmp causes test failure');
2627
}

0 commit comments

Comments
 (0)