Read variable length integer.

@param bool $isCollectionElement
@return string
433766
public function readVarint($isCollectionElement = false) {
		if($isCollectionElement) {
				$length = $this->readShort();
		} else {
				$length = strlen($this->data);
		}

		$hex = unpack('H*', $this->read($length));
		return $this->bchexdec($hex[1]);
	}
1271956
function stream_read($count) {
        $ret = substr($this->_data, $this->_position, $count);
        $this->_position += strlen($ret);
        return $ret;
    }
787960
function readBigInt($isCollectionElement = false) {
		if ($isCollectionElement) {
			$length = $this->readShort();
		} else {
			$length = 8;
		}
		$data = $this->read($length);
		$arr = unpack('N2', $data);

		if (PHP_INT_SIZE == 4) {
			$hi = $arr[1];
			$lo = $arr[2];
			$isNeg = $hi  < 0;
			
			// Check for a negative
			if ($isNeg) {
				$hi = ~$hi & (int)0xffffffff;
				$lo = ~$lo & (int)0xffffffff;
				
				if ($lo == (int)0xffffffff) {	
					$hi++;
					$lo = 0;
				} else {
					$lo++;
				}
			}
			
			// Force 32bit words in excess of 2G to pe positive - we deal wigh sign
			// explicitly below
			if ($hi & (int)0x80000000) {
				$hi &= (int)0x7fffffff;
				$hi += 0x80000000;
			}
			
			if ($lo & (int)0x80000000) {
				$lo &= (int)0x7fffffff;
				$lo += 0x80000000;
			}
			
			$value = $hi * 4294967296 + $lo;
			
			if ($isNeg) {
				$value = 0 - $value;
			}
		} else {
			if ($arr[2] & 0x80000000) {
				$arr[2] = $arr[2] & 0xffffffff;
			}
			
			if ($arr[1] & 0x80000000) {
				$arr[1] = $arr[1] & 0xffffffff;
				$arr[1] = $arr[1] ^ 0xffffffff;
				$arr[2] = $arr[2] ^ 0xffffffff;
				$value = 0 - $arr[1]*4294967296 - $arr[2] - 1;
			} else {
				$value = $arr[1]*4294967296 + $arr[2];
			}
		}

		return $value;
 	}
214880
public function read(int $length = null): string
    {
        // can not call fgets with null when not specified
        $data = null === $length ? fgets($this->resource) : fgets($this->resource, $length);
        if (false === $data) {
            // fgets() returns false on eof while feof() returned false before
            // but will now return true
            if ($this->eof()) {
                return '';
            }

            if (stream_get_meta_data($this->resource)['timed_out']) {
                throw new Timeout(
                        'Reading of ' . $length . ' bytes failed: timeout of '
                        . $this->timeout . ' seconds exceeded'
                );
            }

            throw new ConnectionFailure(
                    'Reading of ' . $length . ' bytes failed.'
            );
        }

        return $data;
    }
724756
public function stream_read($count)
    {
        $ret = substr($this->data, $this->position, $count);
        $this->position += strlen($ret);
        return $ret;
    }
926613
public static Object getElementFromCollection(Collection<Object> collection, int index) {
    if (collection.size() < index + 1)
      return null;

    if (collection instanceof List)
      return ((List<Object>) collection).get(index);

    Iterator<Object> iterator = collection.iterator();
    for (int i = 0; i < index; i++) {
      iterator.next();
    }
    return iterator.next();
  }
827836
function fetchCollectionAttributeHTTPInput( $collection, $collectionAttribute, $http, $base, $contentObjectAttribute )
    {
        if ( $http->hasPostVariable( $base . "_data_integer_" . $contentObjectAttribute->attribute( "id" ) ) )
        {
            $data = $http->postVariable( $base . "_data_integer_" . $contentObjectAttribute->attribute( "id" ) );
            $data = trim( $data ) != '' ? $data : null;
            $data = str_replace(" ", "", $data);
            $collectionAttribute->setAttribute( "data_int", $data );
            return true;
        }
        return false;
    }
1319097
public function stream_read($count)
    {
        $ret = mb_substr($this->data, $this->position, $count);
        $this->position += mb_strlen($ret);

        return $ret;
    }
1179956
public function read_value($fieldType, $collectionsAsObjects = false)
    {
        $this->bitcount = $this->bits = 0;

        switch ($fieldType) {
            case AMQPAbstractCollection::T_INT_SHORTSHORT:
                //according to AMQP091 spec, 'b' is not bit, it is short-short-int, also valid for rabbit/qpid
                //$val=$this->read_bit();
                $val = $this->read_signed_octet();
                break;
            case AMQPAbstractCollection::T_INT_SHORTSHORT_U:
                $val = $this->read_octet();
                break;
            case AMQPAbstractCollection::T_INT_SHORT:
                $val = $this->read_signed_short();
                break;
            case AMQPAbstractCollection::T_INT_SHORT_U:
                $val = $this->read_short();
                break;
            case AMQPAbstractCollection::T_INT_LONG:
                $val = $this->read_signed_long();
                break;
            case AMQPAbstractCollection::T_INT_LONG_U:
                $val = $this->read_long();
                break;
            case AMQPAbstractCollection::T_INT_LONGLONG:
                $val = $this->read_signed_longlong();
                break;
            case AMQPAbstractCollection::T_INT_LONGLONG_U:
                $val = $this->read_longlong();
                break;
            case AMQPAbstractCollection::T_DECIMAL:
                $e = $this->read_octet();
                $n = $this->read_signed_long();
                $val = new AMQPDecimal($n, $e);
                break;
            case AMQPAbstractCollection::T_TIMESTAMP:
                $val = $this->read_timestamp();
                break;
            case AMQPAbstractCollection::T_BOOL:
                $val = $this->read_octet();
                break;
            case AMQPAbstractCollection::T_STRING_SHORT:
                $val = $this->read_shortstr();
                break;
            case AMQPAbstractCollection::T_STRING_LONG:
                $val = $this->read_longstr();
                break;
            case AMQPAbstractCollection::T_ARRAY:
                $val = $this->read_array($collectionsAsObjects);
                break;
            case AMQPAbstractCollection::T_TABLE:
                $val = $this->read_table($collectionsAsObjects);
                break;
            case AMQPAbstractCollection::T_VOID:
                $val = null;
                break;
            case AMQPAbstractCollection::T_BYTES:
                $val = $this->read_longstr();
                break;
            default:
                throw new AMQPInvalidArgumentException(sprintf(
                    'Unsupported type "%s"',
                    $fieldType
                ));
        }

        return isset($val) ? $val : null;
    }
126028
public function stream_read( $count )
    {
        $ret = substr( $this->string, $this->position, $count );
        $this->position += strlen( $ret );
        return $ret;
    }
100941
public function readLittleEndian($offset, $count, $force_bigendian = false)
    {
        $this->assertOffsetAndLength($offset, $count);
        $r = 0;

        if (ByteBuffer::isLittleEndian() && $force_bigendian == false) {
            for ($i = 0; $i < $count; $i++) {
                $r |= ord($this->_buffer[$offset + $i]) << $i * 8;
            }
        } else {
            for ($i = 0; $i < $count; $i++) {
                $r |= ord($this->_buffer[$offset + $count -1 - $i]) << $i * 8;
            }
        }

        return $r;
    }
315344
public function read($len = null)
    {
        if (!$this->getInitialized()) {
            $this->_initialize();
            $this->checkAttributes();
            $this->setInitialized(true);
        }

        $buffer = $this->in->read($len);

        if ($buffer === -1 || !function_exists($this->function)) {
            return -1;
        }

        $lines = explode("\n", $buffer);

        $filtered = array_map($this->function, $lines);

        $filtered_buffer = implode("\n", $filtered);

        return $filtered_buffer;
    }
743839
public function read_long()
    {
        $this->bitcount = $this->bits = 0;
        list(, $res) = unpack('N', $this->rawread(4));

        return empty($this->is64bits) && self::getLongMSB($res) ? sprintf('%u', $res) : $res;
    }
151578
public function nodeString($indent = '', $isChild = false)
    {
        // non printable characters regex
        $nonPrintable = '#[^\x20-\x7E]#';

        //formatters
        $lt = '<';
        $gt = '>';
        $nl = "\n";
        if (!self::isCli()) {
            $lt = '&lt;';
            $gt = '&gt;';
            $nl = '<br />';
            $indent = str_replace(' ', '&nbsp;', $indent);
        }

        $ret = $indent.$lt.$this->tag;
        if ($this->attributeHash != null) {
            foreach ($this->attributeHash as $key => $value) {
                $ret .= ' '.$key.'="'.$value.'"';
            }
        }
        $ret .= $gt;
        if (strlen($this->data) > 0) {
            if (strlen($this->data) <= 1024) {
                //message
                if (preg_match($nonPrintable, $this->data)) {
                    $ret .= bin2hex($this->data);
                } else {
                    $ret .= $this->data;
                }
            } else {
                //raw data
                $ret .= ' '.strlen($this->data).' byte data';
            }
        }
        if ($this->children) {
            $ret .= $nl;
            $foo = [];
            foreach ($this->children as $child) {
                $foo[] = $child->nodeString($indent.'  ', true);
            }
            $ret .= implode($nl, $foo);
            $ret .= $nl.$indent;
        }
        $ret .= $lt.'/'.$this->tag.$gt;

        if (!$isChild) {
            $ret .= $nl;
            if (!self::isCli()) {
                $ret .= $nl;
            }
        }

        return $ret;
    }
251752
public function read($count)
    {
        if ($this->isEof()) {
            return null;
        }
        $buffer         = substr($this->buffer, $this->position, $count);
        $this->position += $count;
        return $buffer;
    }
1242222
private function findElement() {

        // Keep looping while we look for the set element
        while($this->getStream()){

            $streamLength = mb_strlen($this->stream);
            // Check to make sure that we do not miss the string because it has been broken in half.
            if($streamLength > mb_strlen($this->loader->getElement()) && $streamLength > (3 * $this->loader->getBytes())) {
                $this->stream = substr($this->stream, $this->loader->getBytes());
            }

            $found_element = strpos($this->stream, $this->loader->getElement());

            if($found_element !== false) {
                return $this->trimStream();
            }
        }

        $this->arrayEnd = true;
        return false;
    }
1309104
public function read_php_int()
    {
        list(, $res) = unpack('N', $this->rawread(4));

        if ($this->is64bits) {
            return (int) sprintf('%u', $res);
        }

        return $res;
    }