From 342cabc5d048ebafa532aaab3eedc3578cb02ff9 Mon Sep 17 00:00:00 2001 From: Greg Bowler Date: Wed, 18 Oct 2023 22:42:55 +0100 Subject: [PATCH] tweak: return ServerRequestInterface closes #215 --- src/RequestFactory.php | 7 +++++-- src/Response.php | 2 ++ 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/RequestFactory.php b/src/RequestFactory.php index 192e302..6219a10 100644 --- a/src/RequestFactory.php +++ b/src/RequestFactory.php @@ -2,6 +2,7 @@ namespace Gt\Http; use Gt\Http\Header\RequestHeaders; +use Psr\Http\Message\ServerRequestInterface; use Psr\Http\Message\UriInterface; class RequestFactory { @@ -22,13 +23,14 @@ public function createServerRequestFromGlobalState( array $get, array $post, string $inputPath = "php://input" - ):Request { + ):ServerRequestInterface { $method = $server["REQUEST_METHOD"] ?? ""; $uri = $this->buildUri($server); $headers = $this->buildRequestHeaders($server); - return $this->buildRequest( + /** @var ServerRequestInterface $serverRequest */ + $serverRequest = $this->buildRequest( $method, $uri, $headers, @@ -38,6 +40,7 @@ public function createServerRequestFromGlobalState( $post, $inputPath ); + return $serverRequest; } /** diff --git a/src/Response.php b/src/Response.php index b7480f1..83b133c 100644 --- a/src/Response.php +++ b/src/Response.php @@ -234,6 +234,8 @@ public function formData():Promise { * * Note: if no Async loop is set up, the returned Promise will resolve in a blocking way, always being * resolved or rejected. See https://www.php.gt/fetch for a complete async implementation. + * + * @param int<1, max> $depth */ public function json(int $depth = 512, int $options = 0):Promise { $promise = $this->getPromise();