Skip to content

Commit 5265147

Browse files
committed
Add check for empty string to stream factories
1 parent f28c46e commit 5265147

File tree

3 files changed

+6
-2
lines changed

3 files changed

+6
-2
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@
33

44
## Unreleased
55

6+
## Added
7+
8+
- Check for empty string in Stream factories
9+
610
## Fixed
711

812
- FilteredStream::getSize returns null because the contents size is unknown.

src/StreamFactory/DiactorosStreamFactory.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ public function createStream($body = null)
2424
} else {
2525
$stream = new Stream('php://memory', 'rw');
2626

27-
if (null !== $body) {
27+
if (null !== $body || '' !== $body) {
2828
$stream->write((string) $body);
2929
}
3030

src/StreamFactory/SlimStreamFactory.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ public function createStream($body = null)
2828
$resource = fopen('php://memory', 'r+');
2929
$stream = new Stream($resource);
3030

31-
if (null !== $body) {
31+
if (null !== $body || '' !== $body) {
3232
$stream->write((string) $body);
3333
}
3434
}

0 commit comments

Comments
 (0)