public function testDetachClearsBuffer() { $b = new BufferStream(); $b->write('foo'); $b->detach(); $this->assertTrue($b->eof()); $this->assertEquals(3, $b->write('abc')); $this->assertEquals('abc', $b->read(10)); }
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; }