public function encodeVarint($varint)
{
$bytes = [];
$value = $this->is32Bit ? gmp_and($varint, '0x0ffffffffffffffff') : sprintf('%u', $varint);
while (gmp_cmp($value, $this->gmp_x00) > 0) {
$bytes[] = gmp_intval(gmp_and($value, $this->gmp_x7f)) | 0x80;
$value = gmp_div_q($value, $this->gmp_x80);
}
return $bytes;
}