M src/StringStream.php => src/StringStream.php +1 -1
@@ 109,7 109,7 @@ class StringStream implements StreamInterface
*/
public function eof(): bool
{
- return $this->pointer === $this->length;
+ return $this->pointer >= $this->length;
}
/**
M tests/StringStreamTest.php => tests/StringStreamTest.php +9 -0
@@ 207,4 207,13 @@ class StringStreamTest extends TestCase
$this->expectExceptionMessage("You cannot call `getContents' on this stream because it's closed.");
$stringStream->getContents();
}
+
+ public function testEOFAfterOverReading(): void
+ {
+ $stringStream = new StringStream('hello world');
+ self::assertFalse($stringStream->eof());
+ $text = $stringStream->read(1048576);
+ self::assertSame('hello world', $text);
+ self::assertTrue($stringStream->eof());
+ }
}