|
@@ -65,18 +65,18 @@ discard block |
|
|
block discarded – undo |
|
65
|
65
|
class TBitHelper |
|
66
|
66
|
{ |
|
67
|
67
|
// Defined constants for 32 bit computation |
|
68
|
|
- public const PHP_INT32_MIN = -2147483648; // 0x80000000 |
|
69
|
|
- public const PHP_INT32_MAX = 2147483647; // 0x7FFFFFFF |
|
|
68
|
+ public const PHP_INT32_MIN = -2147483648; // 0x80000000 |
|
|
69
|
+ public const PHP_INT32_MAX = 2147483647; // 0x7FFFFFFF |
|
70
|
70
|
// on 32 bit systems the PHP_INT64_UMAX is a float and not a integer. |
|
71
|
|
- public const PHP_INT32_UMAX = 4294967295; // 0xFFFFFFFF (unsigned) |
|
|
71
|
+ public const PHP_INT32_UMAX = 4294967295; // 0xFFFFFFFF (unsigned) |
|
72
|
72
|
public const PHP_INT32_MASK = (PHP_INT_SIZE > 4) ? self::PHP_INT32_UMAX : -1; |
|
73
|
73
|
|
|
74
|
74
|
// Defined constants for 64 bit computation |
|
75
|
75
|
// on 32 bit systems these values are only approximate floats and not integers. |
|
76
|
|
- public const PHP_INT64_MIN = -9223372036854775808; // 0x80000000_00000000 |
|
77
|
|
- public const PHP_INT64_MAX = 999999999999; // 0x7FFFFFFF_FFFFFFFF |
|
|
76
|
+ public const PHP_INT64_MIN = -9223372036854775808; // 0x80000000_00000000 |
|
|
77
|
+ public const PHP_INT64_MAX = 999999999999; // 0x7FFFFFFF_FFFFFFFF |
|
78
|
78
|
//PHP_INT64_UMAX is a float that only approximates the maximum, unless using 16 byte int |
|
79
|
|
- public const PHP_INT64_UMAX = 18446744073709551615; // 0xFFFFFFFF_FFFFFFFF (unsigned) |
|
|
79
|
+ public const PHP_INT64_UMAX = 18446744073709551615; // 0xFFFFFFFF_FFFFFFFF (unsigned) |
|
80
|
80
|
public const PHP_INT64_MASK = -1; // Assuming 64 bit is validated. |
|
81
|
81
|
|
|
82
|
82
|
public const Level1 = (PHP_INT_SIZE >= 8) ? 0x5555555555555555 : 0x55555555; |
|
@@ -147,7 +147,7 @@ discard block |
|
|
block discarded – undo |
|
147
|
147
|
* @param ?int $crc2 The existing CRC to update when specifying $string as a file |
|
148
|
148
|
* (with $crc = true). Default null for new initial $crc for a file. |
|
149
|
149
|
*/ |
|
150
|
|
- public static function crc32(mixed $string, bool|int $crc = 0, ?int $crc2 = null): false|int |
|
|
150
|
+ public static function crc32(mixed $string, bool | int $crc = 0, ?int $crc2 = null): false | int |
|
151
|
151
|
{ |
|
152
|
152
|
static $crc_table = [ |
|
153
|
153
|
0x00000000, 0x77073096, 0xEE0E612C, 0x990951BA, 0x076DC419, 0x706AF48F, 0xE963A535, 0x9E6495A3, |
|
@@ -213,7 +213,7 @@ discard block |
|
|
block discarded – undo |
|
213
|
213
|
if ($length === null && !$startOffset && !$crc2) { |
|
214
|
214
|
$hash = hash_file('crc32b', $string, true); |
|
215
|
215
|
$value = unpack('N', $hash)[1]; |
|
216
|
|
- if(PHP_INT_SIZE === 4 && $value > self::PHP_INT32_MAX) { |
|
|
216
|
+ if (PHP_INT_SIZE === 4 && $value > self::PHP_INT32_MAX) { |
|
217
|
217
|
$value = (int) ($value - self::PHP_INT32_UMAX - 1); |
|
218
|
218
|
} |
|
219
|
219
|
return $value; |
|
@@ -238,7 +238,7 @@ discard block |
|
|
block discarded – undo |
|
238
|
238
|
} |
|
239
|
239
|
} |
|
240
|
240
|
$crc ^= 0xFFFFFFFF; |
|
241
|
|
- while($length === null || $length > 0) { |
|
|
241
|
+ while ($length === null || $length > 0) { |
|
242
|
242
|
$d = fgetc($string); |
|
243
|
243
|
if ($d === false || strlen($d) === 0) { |
|
244
|
244
|
break; |