diff --git a/psalm-baseline.xml b/psalm-baseline.xml
index 17bb976e..e57e265e 100644
--- a/psalm-baseline.xml
+++ b/psalm-baseline.xml
@@ -69,7 +69,6 @@
-
$headers
$method
@@ -85,12 +84,8 @@
$requestTarget
$uri
-
- Request
-
-
$body
$headers
@@ -101,19 +96,11 @@
$request->getHeaders()
-
- Request
-
is_string($method)
-
- RequestInterface
- RequestInterface
- RequestInterface
-
$requestTarget
diff --git a/src/RequestTrait.php b/src/RequestTrait.php
index dd4fe6f5..d23ad1ab 100644
--- a/src/RequestTrait.php
+++ b/src/RequestTrait.php
@@ -158,6 +158,7 @@ public function getRequestTarget(): string
*
* @param string $requestTarget
* @throws Exception\InvalidArgumentException If the request target is invalid.
+ * @return static
*/
public function withRequestTarget($requestTarget): RequestInterface
{
@@ -195,6 +196,7 @@ public function getMethod(): string
*
* @param string $method Case-insensitive method.
* @throws Exception\InvalidArgumentException For invalid HTTP methods.
+ * @return static
*/
public function withMethod($method): RequestInterface
{
@@ -242,6 +244,7 @@ public function getUri(): UriInterface
*
* @param UriInterface $uri New request URI to use.
* @param bool $preserveHost Preserve the original state of the Host header.
+ * @return static
*/
public function withUri(UriInterface $uri, $preserveHost = false): RequestInterface
{
diff --git a/test/StaticAnalysis/RequestInterfaceStaticReturnTypes.php b/test/StaticAnalysis/RequestInterfaceStaticReturnTypes.php
new file mode 100644
index 00000000..d557f872
--- /dev/null
+++ b/test/StaticAnalysis/RequestInterfaceStaticReturnTypes.php
@@ -0,0 +1,44 @@
+withMethod('GET');
+ }
+
+ public function changeRequestTargetOfServerRequest(ServerRequest $request): ServerRequestInterface
+ {
+ return $request->withRequestTarget('foo');
+ }
+
+ public function changeUriOfServerRequest(ServerRequest $request): ServerRequestInterface
+ {
+ return $request->withUri(new Uri('/there'));
+ }
+
+ public function changeMethodOfRequest(Request $request): RequestInterface
+ {
+ return $request->withMethod('GET');
+ }
+
+ public function changeRequestTargetOfRequest(Request $request): RequestInterface
+ {
+ return $request->withRequestTarget('foo');
+ }
+
+ public function changeUriOfRequest(Request $request): RequestInterface
+ {
+ return $request->withUri(new Uri('/there'));
+ }
+}