Reads string from buffer

@return String
772575
@Override
	public String getString() {
		log.trace("getString - currentDataType: {}", currentDataType);
		byte lastDataType = currentDataType;
		// temporarily set to string for reading
		if (currentDataType != AMF.TYPE_STRING) {
			currentDataType = AMF.TYPE_STRING;
		}
		String result = readString();
		// set data type back to what it was
		currentDataType = lastDataType;
		return result;
	}
290921
public String readString()
        throws IOException
    {
        int tag = is.read();

        if (tag == 'N')
            return null;

        if (tag != 'S')
            throw expect("string", tag);

        int b16 = is.read();
        int b8 = is.read();

        int len = (b16 << 8) + b8;

        return readStringImpl(len);
    }
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;
    }
630785
protected function readToBuffer()
    {
        $this->ThrowOnConnectionInvalid();
        $message = stream_socket_recvfrom($this->connection, 1024, 0, $peer);
        //$message = fread($conn,1024);
        if ($message !== '' && $message !== false) {
            $this->buffer->pushData($message);
            foreach ($this->buffer->getMessages() as $messageData) {
                $messageData = unserialize($messageData);
                $this->emit('message', array($this, $messageData));
            }
        } else {
            $this->close();
        }
    }
8538
public function parseEncodedString()
    {
        $l = $this->parseEncodedBinary();
        if (($l === null) || ($l === false)) {
            return $l;
        }
        return $this->read($l);
    }
562569
private function readString($length)
    {
        $result = substr($this->buffer, $this->position, $length);
        $this->position += $length;

        return $result;
    }
832556
public function readLine($length = 1024)
    {
        if ($this->ensureContent() === false) {
            return false;
        }

        $line = '';
        while ($this->ensureContent()) {
            $char = $this->readByte();

            if ($char === "\n") {
                break;
            }

            if ($char === "\r") {
                if ($this->getByte() === "\n") {
                    $this->addOffset(1);
                }
                break;
            }

            $line .= $char;

            if (\strlen($line) >= $length) {
                break;
            }
        }

        return $line;
    }
245754
public static String readString(DataInput in) throws IOException {
    int length = readVInt(in);
    if (length == -1) return null;
    byte[] buffer = new byte[length];
    in.readFully(buffer);
    return Text.decode(buffer);
  }
1353111
public function read($len = null)
    {
        if (!$this->getInitialized()) {
            $this->_initialize();
            $this->setInitialized(true);
        }

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

        if ($buffer === -1) {
            return -1;
        }

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

        foreach ($lines as $line) {
            $line = $this->_prefix . $line;
            $filtered[] = $line;
        }

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

        return $filtered_buffer;
    }
838131
public function read($length)
    {
        $buffer = '';
        $total = count($this->streams) - 1;
        $remaining = $length;

        while ($remaining > 0) {
            // Progress to the next stream if needed.
            if ($this->streams[$this->current]->eof()) {
                if ($this->current == $total) {
                    break;
                }
                $this->current++;
            }
            $buffer .= $this->streams[$this->current]->read($remaining);
            $remaining = $length - strlen($buffer);
        }

        $this->pos += strlen($buffer);

        return $buffer;
    }
606603
public function read()
    {
        $data = @fread($this->stream, 30000);

        if($data === false) return;
        $this->buffer .= $data;

        if(!is_null($this->status)) return;
        if(strlen($this->buffer) < 4) return;
        $end = strpos($this->buffer, "\r\n\r\n", 4);
        if($end === false) return;

        list($request, $headers) = $this->parse_header(substr($this->buffer, 0, $end));
        list($version, $status, $phrase) = explode(' ', $request, 3);
        $this->status = $status;
        $this->response_length = isset($headers['content-length'])? (int)$headers['content-length'][0] : 0;
    }
457424
public function readLast()
    {

        $len = strlen($this->data);
        $string = $this->data{strlen($this->data) - 1};
        $this->data = substr($this->data, 0, $len - 1);
        $this->length -= 1;

        return $string;
    }
11398
protected function Read()
	{
		$ch;
		if ( count( $this->m_buffer ) > 0 )
		{
		    $ch = array_shift( $this->m_buffer );
		}
		else
		{
		    $c = $this->m_reader->read();
		    if ( $c == -1 )
		        return '\0';
		    else
		        $ch = $c;
		}
		if ( $ch != '\r' )
		{
		    if ( $ch == '\n' )
		    {
		        $this->LineNo++;
		        $this->ColNo = 1;
		    }
		    else
		        ++$this->ColNo;
		}
		$this->m_position++;
		return $ch;
	}
1086752
public function read()
	{
		$this->position++;
		if ( $this->position >= count( $this->buffer ) ) return false;

		return $this->buffer[ $this->position ];
	}
186070
public function readDouble() {

            $double = $this->readBuffer(8);

            $testEndian = unpack("C*",pack("S*",256));
            $bigEndian = !$testEndian[1]==1;
                        
            if ($bigEndian) $double = strrev($double);
            $double = unpack("d",$double);
            return $double[1];
        }
590297
public function readByte()
    {
        if (($this->_needle + 1) > $this->_streamLength) {
            require_once 'Zend/Amf/Exception.php';
            throw new Zend_Amf_Exception('Buffer underrun at needle position: ' . $this->_needle . ' while requesting length: ' . $length);
        }

        return ord($this->_stream{$this->_needle++});
    }
1257865
private function read(): string
    {
        $this->lastResponse = fread($this->stream, 1024); // Read up to 1KB
        $this->lastResponseCode = intval(explode(" ", $this->lastResponse)[0]);
        $this->lastResponseCode = $this->lastResponseCode > 0 ? $this->lastResponseCode : -1;
        return $this->lastResponse;
    }