63) { throw new RuntimeException('Varint too long (max 64 bits)'); } } throw new RuntimeException('Unexpected end of varint data'); } /** * Read a varint and return both the value and remaining data. * * @param string $data Binary data starting with varint * @return array{0: int, 1: string} [decoded value, remaining data] */ public static function decodeFirst(string $data): array { $offset = 0; $value = self::decode($data, $offset); $remainder = substr($data, $offset); return [$value, $remainder]; } }