Skip to content

Commit

Permalink
Drop support for "GMP integer" resources
Browse files Browse the repository at this point in the history
GMP always returns \GMP objects starting with PHP 5.6.0.
  • Loading branch information
fpoirotte committed May 12, 2018
1 parent 9147956 commit 75f9262
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 8 deletions.
3 changes: 1 addition & 2 deletions src/NativeEncoder.php
Original file line number Diff line number Diff line change
Expand Up @@ -302,8 +302,7 @@ public static function convert($value)
return $value;
}

if ($value instanceof \GMP ||
(is_resource($value) && get_resource_type($value) === 'GMP integer')) {
if ($value instanceof \GMP) {
$candidates = array(
'\\fpoirotte\\XRL\\Types\\I4',
'\\fpoirotte\\XRL\\Types\\I8',
Expand Down
4 changes: 1 addition & 3 deletions src/Types/AbstractInteger.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,7 @@ public function set($value)
{
$size = static::INTEGER_BITS;

// Versions before PHP 5.6 used resources to represent big numbers
// while new versions use objects instead.
if ((is_resource($value) && get_resource_type($value) === 'GMP integer') || ($value instanceof \GMP)) {
if (is_object($value) && $value instanceof \GMP) {
$value = gmp_strval($value, 10);
}

Expand Down
4 changes: 1 addition & 3 deletions src/Types/BigInteger.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,7 @@ public function set($value)
throw new \RuntimeException("The GMP extension is required for this operation to work");
}

// Versions before PHP 5.6 used resources to represent big numbers
// while new versions use objects instead.
if ((is_resource($value) && get_resource_type($value) === 'GMP integer') || ($value instanceof \GMP)) {
if (is_object($value) && $value instanceof \GMP) {
// It is already a GMP integer.
} else {
$value = @gmp_init($value, 10);
Expand Down

0 comments on commit 75f9262

Please sign in to comment.