Skip to content

Commit

Permalink
Whoops, this only worked when using ReadableBuffer
Browse files Browse the repository at this point in the history
  • Loading branch information
trowski committed Sep 1, 2023
1 parent b94a929 commit 6237100
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/Internal/functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,14 @@
*/
function tryToCreateReadableStreamFromResource($resource): ReadableResourceStream
{
return \is_resource($resource) && \get_resource_type($resource) === 'stream'
? new ReadableResourceStream($resource)
: new ReadableResourceStream(\fopen('php://memory', 'rb'));
if (\is_resource($resource) && \get_resource_type($resource) === 'stream') {
return new ReadableResourceStream($resource);
}

$stream = new ReadableResourceStream(\fopen('php://memory', 'rb'));
$stream->close();

return $stream;
}

/**
Expand Down

0 comments on commit 6237100

Please sign in to comment.