Skip to content
This repository was archived by the owner on Jan 29, 2020. It is now read-only.

Commit 02324e5

Browse files
committed
Merge pull request #257 from sasezaki/fix255
fix #255 - Don't evaluate '0' as empty
2 parents f1b5954 + bee87b2 commit 02324e5

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

src/PhpInputStream.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ public function isWritable()
5959
public function read($length)
6060
{
6161
$content = parent::read($length);
62-
if ($content && ! $this->reachedEof) {
62+
if (! $this->reachedEof) {
6363
$this->cache .= $content;
6464
}
6565

test/PhpInputStreamTest.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,17 @@ public function testGetContentsReturnsRemainingContentsOfStream()
6464
$this->assertEquals(substr($contents, 128), $remainder);
6565
}
6666

67+
public function testGetContentsReturnCacheWhenReachedEof()
68+
{
69+
$this->stream->getContents();
70+
$this->assertStreamContents($this->stream->getContents());
71+
72+
$stream = new PhpInputStream('data://,0');
73+
$stream->read(1);
74+
$stream->read(1);
75+
$this->assertSame('0', $stream->getContents(), 'Don\'t evaluate 0 as empty');
76+
}
77+
6778
public function testCastingToStringReturnsFullContentsRegardlesOfPriorReads()
6879
{
6980
$start = $this->stream->read(128);

0 commit comments

Comments
 (0)