Parse a 16-bit signed integer from the head of the buffer.
@return int
436749
private function parseSignedInt16()
    {
        try {
            $result = \unpack('n', $this->buffer)[1];

            if ($result & 0x8000) {
                return $result - 0x10000;
            }

            return $result;
        } finally {
            $this->buffer = mb_orig_substr($this->buffer, 2);
        }
    }
882523
final public function readInt32LE()
    {
        if ($this->isBigEndian()) {
            return $this->fromInt32(strrev($this->read(4)));
        } else {
            return $this->fromInt32($this->read(4));
        }
    }
1015030
public int readInt() throws IOException {
        int value = 0;
        value += (read() & 0xff) << 0;
        value += (read() & 0xff) << 8;
        value += (read() & 0xff) << 16;
        value += (read() & 0xff) << 24;
        return (int) value;
    }
108787
public function toInteger(): int
    {
        return ($this->myOctets[0] << 24) + ($this->myOctets[1] << 16) + ($this->myOctets[2] << 8) + $this->myOctets[3];
    }
992996
public int readInt () throws KryoException {
		require(4);
		byte[] buffer = this.buffer;
		int p = this.position;
		this.position = p + 4;
		return buffer[p] & 0xFF //
			| (buffer[p + 1] & 0xFF) << 8 //
			| (buffer[p + 2] & 0xFF) << 16 //
			| (buffer[p + 3] & 0xFF) << 24;
	}
1171837
public static function getLong( $b, $offset )
    {
        $val =  (
            (ord($b[$offset++]))        | 
            (ord($b[$offset++]) << 8)   | 
            (ord($b[$offset++]) << 16)  | 
            (ord($b[$offset  ]) << 24)
        );

        // convert signed int to unsigned int if on 32 bit operating system
        if ($val < 0 && PHP_INT_SIZE == 4) {
            $val = sprintf("%u", $val);
        } 

        return $val;
    }
1322873
public function parseDouble()
    {
        try {
            if (Endianness::LITTLE()) {
                return \unpack('d', \strrev(mb_orig_substr($this->buffer, 0, 8)))[1];
            }
            return \unpack('d', $this->buffer)[1]; // @codeCoverageIgnore
        } finally {
            $this->buffer = mb_orig_substr($this->buffer, 8);
        }
    }
1352937
private int readInteger() {
        int b = buf.get();
        if (buf.hasRemaining()) {
            int n = 0;
            int result = 0;
            while ((b & 0x80) != 0 && n < 3) {
                result <<= 7;
                result |= (b & 0x7f);
                b = buf.get();
                n++;
            }
            if (n < 3) {
                result <<= 7;
                result |= b;
            } else {
                // use all 8 bits from the 4th byte
                result <<= 8;
                result |= b & 0x0ff;
                // check if the integer should be negative
                if ((result & 0x10000000) != 0) {
                    // extend the sign bit
                    result |= 0xe0000000;
                }
            }
            return result;
        }
        return b;
    }
1060591
private int grabNext16BitInt() throws WsocBufferException {
        int value = 0;
        byte b1;
        byte b2;

        // Network order data should be Big Endian, so first byte read is most significant.  Java is also Big Endian, so...
        b1 = this.grabNextByte();
        b2 = this.grabNextByte();
        // not sure one needs the "&" below - but put it in for safety given the typecasting
        value = ((b1) & 0x000000ff) << 8 | ((b2) & 0x000000ff);

        return value;
    }
1188351
public function parseInteger(string $integer): ?int
    {
        if (array_key_exists($integer, $this->bitAliases)) {
            return $this->bitAliases[$integer];
        }
        if ($integer === 'null') return null;
        if (strpos($integer, '0b') === 0) {
            return (int)base_convert($integer, 2, 10);
        }
        return (int)$integer;
    }
675018
private function read()
    {
        $s = null;

        for (; !feof($this->sock);) {
            if (($line = fgets($this->sock, 1e3)) == null) {
                continue;
            }

            $s = explode(' ', $line)[0];

            if (preg_match('#^[0-9]+$#', $s)) {
                break;
            }
        }

        return (int) $s;
    }
1211878
public final int getUint24() {
        if (position + 2 >= origin + limit) throw new IllegalArgumentException("limit excceed: "
                                                                               + (position - origin + 2));

        byte[] buf = buffer;
        return (0xff & buf[position++]) | ((0xff & buf[position++]) << 8) | ((0xff & buf[position++]) << 16);
    }
552244
def get_uint16(self):
        

        value = self.get_int()
        if value < 0 or value > 65535:
            raise dns.exception.SyntaxError('%d is not an unsigned 16-bit integer' % value)
        return value
904011
final public function readUInt32()
    {
        if (PHP_INT_SIZE < 8) {
            // @codeCoverageIgnoreStart
            if ($this->isLittleEndian()) {
                list(, $lo, $hi) = unpack('S*', $this->read(4));
            } else {
                list(, $hi, $lo) = unpack('S*', $this->read(4));
            }
            return $hi * (0xffff+1) + $lo; // eq $hi << 16 | $lo
            // @codeCoverageIgnoreEnd
        } else {
            list(, $int) = unpack('L*', $this->read(4)) + array(0, 0);
            return $int;
        }
    }
425762
public function parse()
	{
		if ($this->compressed_size >= $this->min_compressed_size)
		{
			// Check ID1, ID2, and CM
			if (substr($this->compressed_data, 0, 3) !== "\x1F\x8B\x08")
			{
				return false;
			}

			// Get the FLG (FLaGs)
			$this->flags = ord($this->compressed_data[3]);

			// FLG bits above (1 << 4) are reserved
			if ($this->flags > 0x1F)
			{
				return false;
			}

			// Advance the pointer after the above
			$this->position += 4;

			// MTIME
			$mtime = substr($this->compressed_data, $this->position, 4);
			// Reverse the string if we're on a big-endian arch because l is the only signed long and is machine endianness
			if (current(unpack('S', "\x00\x01")) === 1)
			{
				$mtime = strrev($mtime);
			}
			$this->MTIME = current(unpack('l', $mtime));
			$this->position += 4;

			// Get the XFL (eXtra FLags)
			$this->XFL = ord($this->compressed_data[$this->position++]);

			// Get the OS (Operating System)
			$this->OS = ord($this->compressed_data[$this->position++]);

			// Parse the FEXTRA
			if ($this->flags & 4)
			{
				// Read subfield IDs
				$this->SI1 = $this->compressed_data[$this->position++];
				$this->SI2 = $this->compressed_data[$this->position++];

				// SI2 set to zero is reserved for future use
				if ($this->SI2 === "\x00")
				{
					return false;
				}

				// Get the length of the extra field
				$len = current(unpack('v', substr($this->compressed_data, $this->position, 2)));
				$this->position += 2;

				// Check the length of the string is still valid
				$this->min_compressed_size += $len + 4;
				if ($this->compressed_size >= $this->min_compressed_size)
				{
					// Set the extra field to the given data
					$this->extra_field = substr($this->compressed_data, $this->position, $len);
					$this->position += $len;
				}
				else
				{
					return false;
				}
			}

			// Parse the FNAME
			if ($this->flags & 8)
			{
				// Get the length of the filename
				$len = strcspn($this->compressed_data, "\x00", $this->position);

				// Check the length of the string is still valid
				$this->min_compressed_size += $len + 1;
				if ($this->compressed_size >= $this->min_compressed_size)
				{
					// Set the original filename to the given string
					$this->filename = substr($this->compressed_data, $this->position, $len);
					$this->position += $len + 1;
				}
				else
				{
					return false;
				}
			}

			// Parse the FCOMMENT
			if ($this->flags & 16)
			{
				// Get the length of the comment
				$len = strcspn($this->compressed_data, "\x00", $this->position);

				// Check the length of the string is still valid
				$this->min_compressed_size += $len + 1;
				if ($this->compressed_size >= $this->min_compressed_size)
				{
					// Set the original comment to the given string
					$this->comment = substr($this->compressed_data, $this->position, $len);
					$this->position += $len + 1;
				}
				else
				{
					return false;
				}
			}

			// Parse the FHCRC
			if ($this->flags & 2)
			{
				// Check the length of the string is still valid
				$this->min_compressed_size += $len + 2;
				if ($this->compressed_size >= $this->min_compressed_size)
				{
					// Read the CRC
					$crc = current(unpack('v', substr($this->compressed_data, $this->position, 2)));

					// Check the CRC matches
					if ((crc32(substr($this->compressed_data, 0, $this->position)) & 0xFFFF) === $crc)
					{
						$this->position += 2;
					}
					else
					{
						return false;
					}
				}
				else
				{
					return false;
				}
			}

			// Decompress the actual data
			if (($this->data = gzinflate(substr($this->compressed_data, $this->position, -8))) === false)
			{
				return false;
			}
			else
			{
				$this->position = $this->compressed_size - 8;
			}

			// Check CRC of data
			$crc = current(unpack('V', substr($this->compressed_data, $this->position, 4)));
			$this->position += 4;
			/*if (extension_loaded('hash') && sprintf('%u', current(unpack('V', hash('crc32b', $this->data)))) !== sprintf('%u', $crc))
			{
				return false;
			}*/

			// Check ISIZE of data
			$isize = current(unpack('V', substr($this->compressed_data, $this->position, 4)));
			$this->position += 4;
			if (sprintf('%u', strlen($this->data) & 0xFFFFFFFF) !== sprintf('%u', $isize))
			{
				return false;
			}

			// Wow, against all odds, we've actually got a valid gzip string
			return true;
		}
		else
		{
			return false;
		}
	}
381245
private double parseDouble()
        throws IOException
    {
        long b64 = read();
        long b56 = read();
        long b48 = read();
        long b40 = read();
        long b32 = read();
        long b24 = read();
        long b16 = read();
        long b8 = read();

        long bits = ((b64 << 56) +
            (b56 << 48) +
            (b48 << 40) +
            (b40 << 32) +
            (b32 << 24) +
            (b24 << 16) +
            (b16 << 8) +
                b8);

        return Double.longBitsToDouble(bits);
    }
390239
public function decodeMpint()
    {
        $s = $this->decodeString();
        if ($s === null) {
            return null;
        }

        if ($s === '') {
            return gmp_init(0);
        }

        $n = gmp_init(bin2hex($s), 16);

        // Negative numbers: decode using two-complement.
        if (ord($s[0]) & 0x80) {
            // gmp_com() uses the number's size to compute
            // the complement, which is right in our case.
            $n = gmp_neg(gmp_add(gmp_com($n), "1"));
        }
        return $n;
    }