Преглед изворни кода

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.
Daniele Alessandri пре 8 година
родитељ
комит
81c0a8f051

+ 2 - 1
src/Connection/StreamConnection.php

@@ -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);

+ 2 - 1
src/Protocol/Text/Handler/IntegerResponse.php

@@ -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') {

+ 2 - 1
src/Protocol/Text/ProtocolProcessor.php

@@ -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);