Skip to content

Commit 64e8642

Browse files
author
Trevor North
committed
Provide native return type hints for ServerRequest helpers
1 parent 9ada50c commit 64e8642

1 file changed

Lines changed: 17 additions & 17 deletions

File tree

src/ServerRequest.php

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -762,7 +762,7 @@ public function withUri(UriInterface $uri, $preserveHost = false)
762762
*
763763
* @return string|null
764764
*/
765-
public function getContentCharset()
765+
public function getContentCharset(): ?string
766766
{
767767
$mediaTypeParams = $this->getMediaTypeParams();
768768

@@ -780,7 +780,7 @@ public function getContentCharset()
780780
*
781781
* @return string|null The serverRequest content type, if known
782782
*/
783-
public function getContentType()
783+
public function getContentType(): ?string
784784
{
785785
$result = $this->serverRequest->getHeader('Content-Type');
786786
return $result ? $result[0] : null;
@@ -793,7 +793,7 @@ public function getContentType()
793793
*
794794
* @return int|null
795795
*/
796-
public function getContentLength()
796+
public function getContentLength(): ?int
797797
{
798798
$result = $this->serverRequest->getHeader('Content-Length');
799799
return $result ? (int) $result[0] : null;
@@ -828,7 +828,7 @@ public function getCookieParam($key, $default = null)
828828
*
829829
* @return string|null The serverRequest media type, minus content-type params
830830
*/
831-
public function getMediaType()
831+
public function getMediaType(): ?string
832832
{
833833
$contentType = $this->getContentType();
834834

@@ -848,9 +848,9 @@ public function getMediaType()
848848
*
849849
* Note: This method is not part of the PSR-7 standard.
850850
*
851-
* @return array
851+
* @return mixed[]
852852
*/
853-
public function getMediaTypeParams()
853+
public function getMediaTypeParams(): array
854854
{
855855
$contentType = $this->getContentType();
856856
$contentTypeParams = [];
@@ -901,9 +901,9 @@ public function getParam($key, $default = null)
901901
*
902902
* Note: This method is not part of the PSR-7 standard.
903903
*
904-
* @return array
904+
* @return mixed[]
905905
*/
906-
public function getParams()
906+
public function getParams(): ?array
907907
{
908908
$params = $this->getQueryParams();
909909
$postParams = $this->getParsedBody();
@@ -1003,7 +1003,7 @@ public function registerMediaTypeParser($mediaType, callable $callable)
10031003
*
10041004
* @return bool
10051005
*/
1006-
public function isDelete()
1006+
public function isDelete(): bool
10071007
{
10081008
return $this->isMethod('DELETE');
10091009
}
@@ -1015,7 +1015,7 @@ public function isDelete()
10151015
*
10161016
* @return bool
10171017
*/
1018-
public function isGet()
1018+
public function isGet(): bool
10191019
{
10201020
return $this->isMethod('GET');
10211021
}
@@ -1027,7 +1027,7 @@ public function isGet()
10271027
*
10281028
* @return bool
10291029
*/
1030-
public function isHead()
1030+
public function isHead(): bool
10311031
{
10321032
return $this->isMethod('HEAD');
10331033
}
@@ -1040,7 +1040,7 @@ public function isHead()
10401040
* @param string $method HTTP method
10411041
* @return bool
10421042
*/
1043-
public function isMethod($method)
1043+
public function isMethod($method): bool
10441044
{
10451045
return $this->serverRequest->getMethod() === $method;
10461046
}
@@ -1052,7 +1052,7 @@ public function isMethod($method)
10521052
*
10531053
* @return bool
10541054
*/
1055-
public function isOptions()
1055+
public function isOptions(): bool
10561056
{
10571057
return $this->isMethod('OPTIONS');
10581058
}
@@ -1064,7 +1064,7 @@ public function isOptions()
10641064
*
10651065
* @return bool
10661066
*/
1067-
public function isPatch()
1067+
public function isPatch(): bool
10681068
{
10691069
return $this->isMethod('PATCH');
10701070
}
@@ -1076,7 +1076,7 @@ public function isPatch()
10761076
*
10771077
* @return bool
10781078
*/
1079-
public function isPost()
1079+
public function isPost(): bool
10801080
{
10811081
return $this->isMethod('POST');
10821082
}
@@ -1088,7 +1088,7 @@ public function isPost()
10881088
*
10891089
* @return bool
10901090
*/
1091-
public function isPut()
1091+
public function isPut(): bool
10921092
{
10931093
return $this->isMethod('PUT');
10941094
}
@@ -1100,7 +1100,7 @@ public function isPut()
11001100
*
11011101
* @return bool
11021102
*/
1103-
public function isXhr()
1103+
public function isXhr(): bool
11041104
{
11051105
return $this->serverRequest->getHeaderLine('X-Requested-With') === 'XMLHttpRequest';
11061106
}

0 commit comments

Comments
 (0)