Skip to content

Commit ebda9e5

Browse files
committed
Enforce int type on x86 when applicable
1 parent bf4d79b commit ebda9e5

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

src/Thrift/Compact/ReadBuffer.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,10 @@ public function readVarint()
7676
}
7777
if (PHP_INT_SIZE === 4) {
7878
$result = gmp_strval($result, 10);
79+
$intResult = (int) $result;
80+
if ((string) $intResult === $result) {
81+
$result = $intResult;
82+
}
7983
}
8084

8185
return $result;

src/Thrift/Compact/Reader.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,10 @@ private function fromZigZag($n)
187187
}
188188
if (PHP_INT_SIZE === 4) {
189189
$result = gmp_strval($result, 10);
190+
$intResult = (int) $result;
191+
if ((string) $intResult === $result) {
192+
$result = $intResult;
193+
}
190194
}
191195

192196
return $result;

0 commit comments

Comments
 (0)