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

Commit b4048b0

Browse files
committed
Merge pull request #290 from pine3ree/check-fstat-result
check fstat result
2 parents f237ca5 + 45872fd commit b4048b0

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

src/Stream.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,11 @@ public function getSize()
103103
}
104104

105105
$stats = fstat($this->resource);
106-
return $stats['size'];
106+
if ($stats !== false) {
107+
return $stats['size'];
108+
}
109+
110+
return null;
107111
}
108112

109113
/**

test/StreamTest.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -632,4 +632,14 @@ public function testCanReadContentFromNotSeekableResource()
632632

633633
$this->assertSame('FOO BAR', $stream->__toString());
634634
}
635+
636+
/**
637+
* @group 42
638+
*/
639+
public function testSizeReportsNullForPhpInputStreams()
640+
{
641+
$resource = fopen('php://input', 'r');
642+
$stream = new Stream($resource);
643+
$this->assertNull($stream->getSize());
644+
}
635645
}

0 commit comments

Comments
 (0)