From ef7e73e5e872edde487d7587b2cd9ecc2297832b Mon Sep 17 00:00:00 2001 From: Erik Erskine Date: Mon, 13 Nov 2023 18:09:54 +0100 Subject: [PATCH] Add PHP 8.1 return types to the Response class --- src/Http/Response.php | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/src/Http/Response.php b/src/Http/Response.php index 67f8ac2..d556efa 100644 --- a/src/Http/Response.php +++ b/src/Http/Response.php @@ -3,6 +3,7 @@ namespace SevenShores\Hubspot\Http; use ArrayAccess; +use Psr\Http\Message\MessageInterface; use Psr\Http\Message\ResponseInterface; use Psr\Http\Message\StreamInterface; @@ -106,7 +107,7 @@ public function offsetUnset($offset): void * * @return string HTTP protocol version */ - public function getProtocolVersion() + public function getProtocolVersion(): string { return $this->response->getProtocolVersion(); } @@ -125,7 +126,7 @@ public function getProtocolVersion() * * @return self */ - public function withProtocolVersion($version) + public function withProtocolVersion($version): MessageInterface { return $this->response->withProtocolVersion($version); } @@ -155,7 +156,7 @@ public function withProtocolVersion($version) * key MUST be a header name, and each value MUST be an array of strings * for that header. */ - public function getHeaders() + public function getHeaders(): array { return $this->response->getHeaders(); } @@ -169,7 +170,7 @@ public function getHeaders() * name using a case-insensitive string comparison. Returns false if * no matching header name is found in the message. */ - public function hasHeader($name) + public function hasHeader($name): bool { return $this->response->hasHeader($name); } @@ -189,7 +190,7 @@ public function hasHeader($name) * header. If the header does not appear in the message, this method MUST * return an empty array. */ - public function getHeader($name) + public function getHeader($name): array { return $this->response->getHeader($name); } @@ -214,7 +215,7 @@ public function getHeader($name) * concatenated together using a comma. If the header does not appear in * the message, this method MUST return an empty string. */ - public function getHeaderLine($name) + public function getHeaderLine($name): string { return $this->response->getHeaderLine($name); } @@ -236,7 +237,7 @@ public function getHeaderLine($name) * * @return self */ - public function withHeader($name, $value) + public function withHeader($name, $value): MessageInterface { return $this->response->withHeader($name, $value); } @@ -259,7 +260,7 @@ public function withHeader($name, $value) * * @return self */ - public function withAddedHeader($name, $value) + public function withAddedHeader($name, $value): MessageInterface { return $this->response->withAddedHeader($name, $value); } @@ -277,7 +278,7 @@ public function withAddedHeader($name, $value) * * @return self */ - public function withoutHeader($name) + public function withoutHeader($name): MessageInterface { return $this->response->withoutHeader($name); } @@ -287,7 +288,7 @@ public function withoutHeader($name) * * @return StreamInterface returns the body as a stream */ - public function getBody() + public function getBody(): StreamInterface { return $this->response->getBody(); } @@ -307,7 +308,7 @@ public function getBody() * * @return self */ - public function withBody(StreamInterface $body) + public function withBody(StreamInterface $body): MessageInterface { return $this->response->withBody($body); } @@ -320,7 +321,7 @@ public function withBody(StreamInterface $body) * * @return int status code */ - public function getStatusCode() + public function getStatusCode(): int { return $this->response->getStatusCode(); } @@ -348,7 +349,7 @@ public function getStatusCode() * * @return self */ - public function withStatus($code, $reasonPhrase = '') + public function withStatus($code, $reasonPhrase = ''): ResponseInterface { return $this->response->withStatus($code, $reasonPhrase); } @@ -367,7 +368,7 @@ public function withStatus($code, $reasonPhrase = '') * * @return string reason phrase; must return an empty string if none present */ - public function getReasonPhrase() + public function getReasonPhrase(): string { return $this->response->getReasonPhrase(); }