Skip to content

Commit

Permalink
Merge pull request #79 from blubolt/return-types
Browse files Browse the repository at this point in the history
Provide native return type hints for all additional helpers
  • Loading branch information
l0gicgate committed Dec 14, 2018
2 parents 1ac726f + 5d45c06 commit ff98230
Showing 1 changed file with 17 additions and 17 deletions.
34 changes: 17 additions & 17 deletions src/ServerRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -765,7 +765,7 @@ public function withUri(UriInterface $uri, $preserveHost = false)
*
* @return string|null
*/
public function getContentCharset()
public function getContentCharset(): ?string
{
$mediaTypeParams = $this->getMediaTypeParams();

Expand All @@ -783,7 +783,7 @@ public function getContentCharset()
*
* @return string|null The serverRequest content type, if known
*/
public function getContentType()
public function getContentType(): ?string
{
$result = $this->serverRequest->getHeader('Content-Type');
return $result ? $result[0] : null;
Expand All @@ -796,7 +796,7 @@ public function getContentType()
*
* @return int|null
*/
public function getContentLength()
public function getContentLength(): ?int
{
$result = $this->serverRequest->getHeader('Content-Length');
return $result ? (int) $result[0] : null;
Expand Down Expand Up @@ -831,7 +831,7 @@ public function getCookieParam($key, $default = null)
*
* @return string|null The serverRequest media type, minus content-type params
*/
public function getMediaType()
public function getMediaType(): ?string
{
$contentType = $this->getContentType();

Expand All @@ -851,9 +851,9 @@ public function getMediaType()
*
* Note: This method is not part of the PSR-7 standard.
*
* @return array
* @return mixed[]
*/
public function getMediaTypeParams()
public function getMediaTypeParams(): array
{
$contentType = $this->getContentType();
$contentTypeParams = [];
Expand Down Expand Up @@ -904,9 +904,9 @@ public function getParam($key, $default = null)
*
* Note: This method is not part of the PSR-7 standard.
*
* @return array
* @return mixed[]
*/
public function getParams()
public function getParams(): array
{
$params = $this->getQueryParams();
$postParams = $this->getParsedBody();
Expand Down Expand Up @@ -1006,7 +1006,7 @@ public function registerMediaTypeParser($mediaType, callable $callable)
*
* @return bool
*/
public function isDelete()
public function isDelete(): bool
{
return $this->isMethod('DELETE');
}
Expand All @@ -1018,7 +1018,7 @@ public function isDelete()
*
* @return bool
*/
public function isGet()
public function isGet(): bool
{
return $this->isMethod('GET');
}
Expand All @@ -1030,7 +1030,7 @@ public function isGet()
*
* @return bool
*/
public function isHead()
public function isHead(): bool
{
return $this->isMethod('HEAD');
}
Expand All @@ -1043,7 +1043,7 @@ public function isHead()
* @param string $method HTTP method
* @return bool
*/
public function isMethod($method)
public function isMethod($method): bool
{
return $this->serverRequest->getMethod() === $method;
}
Expand All @@ -1055,7 +1055,7 @@ public function isMethod($method)
*
* @return bool
*/
public function isOptions()
public function isOptions(): bool
{
return $this->isMethod('OPTIONS');
}
Expand All @@ -1067,7 +1067,7 @@ public function isOptions()
*
* @return bool
*/
public function isPatch()
public function isPatch(): bool
{
return $this->isMethod('PATCH');
}
Expand All @@ -1079,7 +1079,7 @@ public function isPatch()
*
* @return bool
*/
public function isPost()
public function isPost(): bool
{
return $this->isMethod('POST');
}
Expand All @@ -1091,7 +1091,7 @@ public function isPost()
*
* @return bool
*/
public function isPut()
public function isPut(): bool
{
return $this->isMethod('PUT');
}
Expand All @@ -1103,7 +1103,7 @@ public function isPut()
*
* @return bool
*/
public function isXhr()
public function isXhr(): bool
{
return $this->serverRequest->getHeaderLine('X-Requested-With') === 'XMLHttpRequest';
}
Expand Down

0 comments on commit ff98230

Please sign in to comment.