public function testDetachClearsBuffer() { $buffer = new BufferStream(); $buffer->write('foo'); $buffer->detach(); $this->assertTrue($buffer->eof()); $this->assertEquals(3, $buffer->write('abc')); $this->assertEquals('abc', $buffer->read(10)); }
/** * {@inheritdoc} */ public function read($length) { $data = $this->buffer->read($length); $readLen = strlen($data); $this->tellPos += $readLen; $remaining = $length - $readLen; if ($remaining) { $this->pump($remaining); $data .= $this->buffer->read($remaining); $this->tellPos += strlen($data) - $readLen; } return $data; }