@@ -432,16 +432,16 @@ public static function writeVarInt(int $v) : string{
432
432
*/
433
433
public static function writeUnsignedVarInt (int $ value ) : string {
434
434
$ buf = "" ;
435
- $ value &= 0xffffffff ;
435
+ $ remaining = $ value & 0xffffffff ;
436
436
for ($ i = 0 ; $ i < 5 ; ++$ i ){
437
- if (($ value >> 7 ) !== 0 ){
438
- $ buf .= chr ($ value | 0x80 );
437
+ if (($ remaining >> 7 ) !== 0 ){
438
+ $ buf .= chr ($ remaining | 0x80 );
439
439
}else {
440
- $ buf .= chr ($ value & 0x7f );
440
+ $ buf .= chr ($ remaining & 0x7f );
441
441
return $ buf ;
442
442
}
443
443
444
- $ value = (($ value >> 7 ) & (PHP_INT_MAX >> 6 )); //PHP really needs a logical right-shift operator
444
+ $ remaining = (($ remaining >> 7 ) & (PHP_INT_MAX >> 6 )); //PHP really needs a logical right-shift operator
445
445
}
446
446
447
447
throw new InvalidArgumentException ("Value too large to be encoded as a VarInt " );
@@ -496,15 +496,16 @@ public static function writeVarLong(int $v) : string{
496
496
*/
497
497
public static function writeUnsignedVarLong (int $ value ) : string {
498
498
$ buf = "" ;
499
+ $ remaining = $ value ;
499
500
for ($ i = 0 ; $ i < 10 ; ++$ i ){
500
- if (($ value >> 7 ) !== 0 ){
501
- $ buf .= chr ($ value | 0x80 ); //Let chr() take the last byte of this, it's faster than adding another & 0x7f.
501
+ if (($ remaining >> 7 ) !== 0 ){
502
+ $ buf .= chr ($ remaining | 0x80 ); //Let chr() take the last byte of this, it's faster than adding another & 0x7f.
502
503
}else {
503
- $ buf .= chr ($ value & 0x7f );
504
+ $ buf .= chr ($ remaining & 0x7f );
504
505
return $ buf ;
505
506
}
506
507
507
- $ value = (($ value >> 7 ) & (PHP_INT_MAX >> 6 )); //PHP really needs a logical right-shift operator
508
+ $ remaining = (($ remaining >> 7 ) & (PHP_INT_MAX >> 6 )); //PHP really needs a logical right-shift operator
508
509
}
509
510
510
511
throw new InvalidArgumentException ("Value too large to be encoded as a VarLong " );
0 commit comments