From bf35b7b4397184708321fea028268f6e1e05b3e9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joan=20Fabr=C3=A9gat?= Date: Fri, 27 Jul 2018 13:15:13 +0200 Subject: [PATCH 1/3] bug fix --- src/StreamResponse.php | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/StreamResponse.php b/src/StreamResponse.php index 614ec4c..36280a3 100644 --- a/src/StreamResponse.php +++ b/src/StreamResponse.php @@ -23,6 +23,7 @@ namespace CodeInc\Psr7Responses; use GuzzleHttp\Psr7\Response; use function GuzzleHttp\Psr7\stream_for; +use Psr\Http\Message\StreamInterface; /** @@ -36,7 +37,7 @@ class StreamResponse extends Response { /** - * @var \GuzzleHttp\Psr7\Stream + * @var StreamInterface */ private $stream; @@ -99,11 +100,11 @@ public function __construct($resource, ?string $charset = null, ?int $contentLen } /** - * Returns the stream. + * Returns the resource wrapped into a stream. * - * @return \GuzzleHttp\Psr7\Stream + * @return StreamInterface */ - public function getStream():\GuzzleHttp\Psr7\Stream + public function getStream():StreamInterface { return $this->stream; } From 69742e714e8c05567e1d4ef81aae6784f6459f27 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joan=20Fabr=C3=A9gat?= Date: Fri, 27 Jul 2018 13:15:25 +0200 Subject: [PATCH 2/3] new method StreamResponse::getRawResource() --- src/StreamResponse.php | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/StreamResponse.php b/src/StreamResponse.php index 36280a3..cf929c0 100644 --- a/src/StreamResponse.php +++ b/src/StreamResponse.php @@ -41,6 +41,11 @@ class StreamResponse extends Response */ private $stream; + /** + * @var mixed + */ + private $rawResource; + /** * @var null|string */ @@ -78,6 +83,7 @@ public function __construct($resource, ?string $charset = null, ?int $contentLen ?string $fileName = null, bool $asAttachment = false, int $status = 200, array $headers = [], string $version = '1.1', ?string $reason = null) { + $this->rawResource = $resource; $this->stream = stream_for($resource); $this->charset = $charset; $this->contentLength = $contentLength; @@ -109,6 +115,16 @@ public function getStream():StreamInterface return $this->stream; } + /** + * Returns the raw resource as passed to the constructor. + * + * @return mixed + */ + public function getRawResource() + { + return $this->rawResource; + } + /** * Returns the mime type if set or null. * From f2b65a923914485bd9e2c4807bccf2e99831866a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joan=20Fabr=C3=A9gat?= Date: Fri, 27 Jul 2018 13:15:29 +0200 Subject: [PATCH 3/3] v1.4.1 --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 0a24362..d980be3 100644 --- a/composer.json +++ b/composer.json @@ -1,6 +1,6 @@ { "name": "codeinc/psr7-responses", - "version": "1.4.0", + "version": "1.4.1", "description": "A collection of PSR-7 responses", "homepage": "https://github.com/CodeIncHQ/Psr7Responses", "type": "library",