Skip to content

Commit

Permalink
XdrDecoder - fixed notice about "Only variables should be passed by r…
Browse files Browse the repository at this point in the history
…eference"

Fixes #9
  • Loading branch information
zulucrypto committed Mar 16, 2018
1 parent 0e9fcc5 commit 58da526
Showing 1 changed file with 18 additions and 4 deletions.
22 changes: 18 additions & 4 deletions src/Xdr/XdrDecoder.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ class XdrDecoder
public static function unsignedInteger($xdr)
{
// unsigned 32-bit big-endian
return array_pop(unpack('N', $xdr));
$unpacked = unpack('N', $xdr);
return array_pop($unpacked);
}

/**
Expand All @@ -37,7 +38,13 @@ public static function signedInteger($xdr)
{
// pack() does not support a signed 32-byte int, so work around this with
// custom encoding
return (self::nativeIsBigEndian()) ? array_pop(unpack('l', $xdr)) : array_pop(unpack('l', strrev($xdr)));
if (!self::nativeIsBigEndian()) {
$xdr = strrev($xdr);
}

$unpacked = unpack('l', $xdr);

return array_pop($unpacked);
}

/**
Expand All @@ -50,7 +57,8 @@ public static function unsignedInteger64($xdr)
MathSafety::require64Bit();

// unsigned 64-bit big-endian
return array_pop(unpack('J', $xdr));
$unpacked = unpack('J', $xdr);
return array_pop($unpacked);
}

/**
Expand All @@ -74,7 +82,13 @@ public static function signedInteger64($xdr)

// pack() does not support a signed 64-byte int, so work around this with
// custom encoding
return (self::nativeIsBigEndian()) ? array_pop(unpack('q', $xdr)) : array_pop(unpack('q', strrev($xdr)));
if (!self::nativeIsBigEndian()) {
$xdr = strrev($xdr);
}

$unpacked = unpack('q', $xdr);

return array_pop($unpacked);
}

/**
Expand Down

0 comments on commit 58da526

Please sign in to comment.