Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add type hints and fix docblocks for \Slim\Http\Response #84

Merged
merged 2 commits into from
May 20, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 23 additions & 23 deletions src/Response.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
class Response implements ResponseInterface
{
/**
* @var ResponseInterface;
* @var ResponseInterface
*/
private $response;

Expand Down Expand Up @@ -63,63 +63,63 @@ public function getBody()
/**
* {@inheritdoc}
*/
public function getHeader($name)
public function getHeader($name): array
{
return $this->response->getHeader($name);
}

/**
* {@inheritdoc}
*/
public function getHeaderLine($name)
public function getHeaderLine($name): string
{
return $this->response->getHeaderLine($name);
}

/**
* {@inheritdoc}
*/
public function getHeaders()
public function getHeaders(): array
{
return $this->response->getHeaders();
}

/**
* {@inheritdoc}
*/
public function getProtocolVersion()
public function getProtocolVersion(): string
{
return $this->response->getProtocolVersion();
}

/**
* {@inheritdoc}
*/
public function getReasonPhrase()
public function getReasonPhrase(): string
{
return $this->response->getReasonPhrase();
}

/**
* {@inheritdoc}
*/
public function getStatusCode()
public function getStatusCode(): int
{
return $this->response->getStatusCode();
}

/**
* {@inheritdoc}
*/
public function hasHeader($name)
public function hasHeader($name): bool
{
return $this->response->hasHeader($name);
}

/**
* {@inheritdoc}
*/
public function withAddedHeader($name, $value)
public function withAddedHeader($name, $value): self
{
$response = $this->response->withAddedHeader($name, $value);
return new static($response, $this->streamFactory);
Expand All @@ -128,7 +128,7 @@ public function withAddedHeader($name, $value)
/**
* {@inheritdoc}
*/
public function withBody(StreamInterface $body)
public function withBody(StreamInterface $body): self
{
$response = $this->response->withBody($body);
return new static($response, $this->streamFactory);
Expand All @@ -137,7 +137,7 @@ public function withBody(StreamInterface $body)
/**
* {@inheritdoc}
*/
public function withHeader($name, $value)
public function withHeader($name, $value): self
{
$response = $this->response->withHeader($name, $value);
return new static($response, $this->streamFactory);
Expand All @@ -146,7 +146,7 @@ public function withHeader($name, $value)
/**
* {@inheritdoc}
*/
public function withoutHeader($name)
public function withoutHeader($name): self
{
$response = $this->response->withoutHeader($name);
return new static($response, $this->streamFactory);
Expand All @@ -155,7 +155,7 @@ public function withoutHeader($name)
/**
* {@inheritdoc}
*/
public function withProtocolVersion($version)
public function withProtocolVersion($version): self
{
$response = $this->response->withProtocolVersion($version);
return new static($response, $this->streamFactory);
Expand All @@ -164,7 +164,7 @@ public function withProtocolVersion($version)
/**
* {@inheritdoc}
*/
public function withStatus($code, $reasonPhrase = '')
public function withStatus($code, $reasonPhrase = ''): self
{
$response = $this->response->withStatus($code, $reasonPhrase);
return new static($response, $this->streamFactory);
Expand All @@ -178,13 +178,13 @@ public function withStatus($code, $reasonPhrase = '')
* This method prepares the response object to return an HTTP Json
* response to the client.
*
* @param mixed $data The data
* @param int $status The HTTP status code.
* @param int $options Json encoding options
* @param int $depth Json encoding max depth
* @param mixed $data The data
* @param int|null $status The HTTP status code
* @param int $options Json encoding options
* @param int $depth Json encoding max depth
* @return static
*/
public function withJson($data, int $status = null, int $options = 0, int $depth = 512): ResponseInterface
public function withJson($data, ?int $status = null, int $options = 0, int $depth = 512): ResponseInterface
{
$json = (string) json_encode($data, $options, $depth);

Expand All @@ -211,11 +211,11 @@ public function withJson($data, int $status = null, int $options = 0, int $depth
* This method prepares the response object to return an HTTP Redirect
* response to the client.
*
* @param string $url The redirect destination.
* @param int|null $status The redirect HTTP status code.
* @param string $url The redirect destination.
* @param int|null $status The redirect HTTP status code.
* @return static
*/
public function withRedirect(string $url, $status = null): ResponseInterface
public function withRedirect(string $url, ?int $status = null): ResponseInterface
{
$response = $this->response->withHeader('Location', $url);

Expand All @@ -237,7 +237,7 @@ public function withRedirect(string $url, $status = null): ResponseInterface
* @param string $data
* @return static
*/
public function write($data): ResponseInterface
public function write(string $data): ResponseInterface
{
$this->response->getBody()->write($data);
return $this;
Expand Down