diff --git a/composer.json b/composer.json index 466070c..e1078bb 100644 --- a/composer.json +++ b/composer.json @@ -1,6 +1,6 @@ { "name": "codeinchq/lib-psr7responses", - "version": "1.1.2", + "version": "1.1.3", "description": "A collection of PSR-7 responses", "homepage": "https://github.com/codeinchq/lib-psr7responses", "type": "library", diff --git a/src/FileResponse.php b/src/FileResponse.php index a9b2bde..289dfc3 100644 --- a/src/FileResponse.php +++ b/src/FileResponse.php @@ -36,7 +36,7 @@ class FileResponse extends StreamResponse { * @param string $filePath * @param null|string $fileName * @param null|string $mimeType - * @param bool|null $asAttachment + * @param bool $asAttachment * @param int $status * @param array $headers * @param string $version @@ -44,7 +44,7 @@ class FileResponse extends StreamResponse { * @throws ResponseException */ public function __construct(string $filePath, ?string $fileName = null, ?string $mimeType = null, - ?bool $asAttachment = null, int $status = 200, array $headers = [], + bool $asAttachment = true, int $status = 200, array $headers = [], string $version = '1.1', ?string $reason = null) { if (!is_file($filePath)) { diff --git a/src/StreamResponse.php b/src/StreamResponse.php index 658eaef..c2464ab 100644 --- a/src/StreamResponse.php +++ b/src/StreamResponse.php @@ -23,7 +23,6 @@ namespace CodeInc\Psr7Responses; use GuzzleHttp\Psr7\Response; use function GuzzleHttp\Psr7\stream_for; -use Psr\Http\Message\StreamInterface; /** @@ -36,24 +35,24 @@ class StreamResponse extends Response { /** * StreamResponse constructor. * - * @param resource|string|null|int|float|bool|StreamInterface|callable $resource - * @param null|string $fileName + * @param $resource * @param null|string $mimeType * @param int|null $contentLength - * @param bool|null $asAttachment + * @param null|string $fileName + * @param bool $asAttachment * @param int $status * @param array $headers * @param string $version * @param null|string $reason */ public function __construct($resource, ?string $mimeType = null, ?int $contentLength = null, - ?string $fileName = null, ?bool $asAttachment = null, int $status = 200, array $headers = [], + ?string $fileName = null, bool $asAttachment = false, int $status = 200, array $headers = [], string $version = '1.1', ?string $reason = null) { if ($mimeType) { $headers["Content-Type"] = $mimeType; } - $headers["Content-Disposition"] = $asAttachment !== false ? "attachment" : "inline"; + $headers["Content-Disposition"] = $asAttachment ? "attachment" : "inline"; if ($fileName) { $headers["Content-Disposition"] .= sprintf("; filename=\"%s\"", $fileName); }