mirror of
https://github.com/predis/predis.git
synced 2026-09-01 05:03:28 +00:00
Ensure big ints are not truncated on 32 bits PHP.
We check if the string value is different than the casted int value, if so it means that the integer is beyond PHP_INT_MAX or PHP_INT_MIN and we simply return the string value. This is also useful on Windows builds of PHP since the maximum integer size (prior to PHP 7.0) is 32 bits even for 64 bit builds.
This commit is contained in:
@@ -360,7 +360,8 @@ class StreamConnection extends AbstractConnection
|
||||
return $multibulk;
|
||||
|
||||
case ':':
|
||||
return (int) $payload;
|
||||
$integer = (int) $payload;
|
||||
return $integer == $payload ? $integer : $payload;
|
||||
|
||||
case '-':
|
||||
return new ErrorResponse($payload);
|
||||
|
||||
@@ -31,7 +31,8 @@ class IntegerResponse implements ResponseHandlerInterface
|
||||
public function handle(CompositeConnectionInterface $connection, $payload)
|
||||
{
|
||||
if (is_numeric($payload)) {
|
||||
return (int) $payload;
|
||||
$integer = (int) $payload;
|
||||
return $integer == $payload ? $integer : $payload;
|
||||
}
|
||||
|
||||
if ($payload !== 'nil') {
|
||||
|
||||
@@ -90,7 +90,8 @@ class ProtocolProcessor implements ProtocolProcessorInterface
|
||||
return $multibulk;
|
||||
|
||||
case ':':
|
||||
return (int) $payload;
|
||||
$integer = (int) $payload;
|
||||
return $integer == $payload ? $integer : $payload;
|
||||
|
||||
case '-':
|
||||
return new ErrorResponse($payload);
|
||||
|
||||
Reference in New Issue
Block a user