From: William Desportes <williamdes@wdes.fr>
Date: Fri, 17 Oct 2025 23:11:12 +0200
Subject: Support both psr/http-message v1.1 and v2

Upstream PR 19887 (merged) migrates to psr/http-message v2 by adding typed
method signatures to Http/ServerRequest.php -- the only class implementing the
PSR interfaces. Those signatures are also compatible with the v1.1 interfaces
(adding a return type where the 1.1 interface declares none is allowed,
verified on PHP 8.4), so keep the code but widen the composer constraint to a
range that accepts either version. Debian ships php-psr-http-message 1.1 in
unstable and 2.0 in experimental.

Origin: upstream, https://github.com/phpmyadmin/phpmyadmin/pull/19887
Forwarded: not-needed
---
 composer.json                            |  2 +-
 libraries/classes/Http/ServerRequest.php | 57 ++++++++++++++++----------------
 2 files changed, 30 insertions(+), 29 deletions(-)

diff --git a/composer.json b/composer.json
index c2bbf81..9a6e2dc 100644
--- a/composer.json
+++ b/composer.json
@@ -69,7 +69,7 @@
         "phpmyadmin/sql-parser": "^5.8",
         "phpmyadmin/twig-i18n-extension": ">=4.1.3 < 6.0.0",
         "psr/http-factory": "^1.0",
-        "psr/http-message": "^1.0",
+        "psr/http-message": ">=1.1 <3",
         "slim/psr7": "^1.4.1",
         "symfony/config": ">=5.2.3 <8",
         "symfony/dependency-injection": ">=5.2.3 <8",
diff --git a/libraries/classes/Http/ServerRequest.php b/libraries/classes/Http/ServerRequest.php
index 379371a..3dafad5 100644
--- a/libraries/classes/Http/ServerRequest.php
+++ b/libraries/classes/Http/ServerRequest.php
@@ -4,6 +4,7 @@ declare(strict_types=1);
 
 namespace PhpMyAdmin\Http;
 
+use Psr\Http\Message\MessageInterface;
 use Psr\Http\Message\ServerRequestInterface;
 use Psr\Http\Message\StreamInterface;
 use Psr\Http\Message\UriInterface;
@@ -25,7 +26,7 @@ class ServerRequest implements ServerRequestInterface
     /**
      * @inheritDoc
      */
-    public function getProtocolVersion()
+    public function getProtocolVersion(): string
     {
         return $this->serverRequest->getProtocolVersion();
     }
@@ -33,7 +34,7 @@ class ServerRequest implements ServerRequestInterface
     /**
      * @inheritDoc
      */
-    public function withProtocolVersion($version)
+    public function withProtocolVersion($version): MessageInterface
     {
         $serverRequest = $this->serverRequest->withProtocolVersion($version);
 
@@ -43,7 +44,7 @@ class ServerRequest implements ServerRequestInterface
     /**
      * @inheritDoc
      */
-    public function getHeaders()
+    public function getHeaders(): array
     {
         return $this->serverRequest->getHeaders();
     }
@@ -51,7 +52,7 @@ class ServerRequest implements ServerRequestInterface
     /**
      * @inheritDoc
      */
-    public function hasHeader($name)
+    public function hasHeader(string $name): bool
     {
         return $this->serverRequest->hasHeader($name);
     }
@@ -59,7 +60,7 @@ class ServerRequest implements ServerRequestInterface
     /**
      * @inheritDoc
      */
-    public function getHeader($name)
+    public function getHeader(string $name): array
     {
         return $this->serverRequest->getHeader($name);
     }
@@ -67,7 +68,7 @@ class ServerRequest implements ServerRequestInterface
     /**
      * @inheritDoc
      */
-    public function getHeaderLine($name)
+    public function getHeaderLine(string $name): string
     {
         return $this->serverRequest->getHeaderLine($name);
     }
@@ -75,7 +76,7 @@ class ServerRequest implements ServerRequestInterface
     /**
      * @inheritDoc
      */
-    public function withHeader($name, $value)
+    public function withHeader(string $name, $value): MessageInterface
     {
         $serverRequest = $this->serverRequest->withHeader($name, $value);
 
@@ -85,7 +86,7 @@ class ServerRequest implements ServerRequestInterface
     /**
      * @inheritDoc
      */
-    public function withAddedHeader($name, $value)
+    public function withAddedHeader(string $name, $value): MessageInterface
     {
         $serverRequest = $this->serverRequest->withAddedHeader($name, $value);
 
@@ -95,7 +96,7 @@ class ServerRequest implements ServerRequestInterface
     /**
      * @inheritDoc
      */
-    public function withoutHeader($name)
+    public function withoutHeader(string $name): MessageInterface
     {
         $serverRequest = $this->serverRequest->withoutHeader($name);
 
@@ -105,7 +106,7 @@ class ServerRequest implements ServerRequestInterface
     /**
      * @inheritDoc
      */
-    public function getBody()
+    public function getBody(): StreamInterface
     {
         return $this->serverRequest->getBody();
     }
@@ -113,7 +114,7 @@ class ServerRequest implements ServerRequestInterface
     /**
      * @inheritDoc
      */
-    public function withBody(StreamInterface $body)
+    public function withBody(StreamInterface $body): MessageInterface
     {
         $serverRequest = $this->serverRequest->withBody($body);
 
@@ -123,7 +124,7 @@ class ServerRequest implements ServerRequestInterface
     /**
      * @inheritDoc
      */
-    public function getRequestTarget()
+    public function getRequestTarget(): string
     {
         return $this->serverRequest->getRequestTarget();
     }
@@ -131,7 +132,7 @@ class ServerRequest implements ServerRequestInterface
     /**
      * @inheritDoc
      */
-    public function withRequestTarget($requestTarget)
+    public function withRequestTarget($requestTarget): ServerRequestInterface
     {
         $serverRequest = $this->serverRequest->withRequestTarget($requestTarget);
 
@@ -141,7 +142,7 @@ class ServerRequest implements ServerRequestInterface
     /**
      * @inheritDoc
      */
-    public function getMethod()
+    public function getMethod(): string
     {
         return $this->serverRequest->getMethod();
     }
@@ -149,7 +150,7 @@ class ServerRequest implements ServerRequestInterface
     /**
      * @inheritDoc
      */
-    public function withMethod($method)
+    public function withMethod($method): ServerRequestInterface
     {
         $serverRequest = $this->serverRequest->withMethod($method);
 
@@ -159,7 +160,7 @@ class ServerRequest implements ServerRequestInterface
     /**
      * @inheritDoc
      */
-    public function getUri()
+    public function getUri(): UriInterface
     {
         return $this->serverRequest->getUri();
     }
@@ -167,7 +168,7 @@ class ServerRequest implements ServerRequestInterface
     /**
      * @inheritDoc
      */
-    public function withUri(UriInterface $uri, $preserveHost = false)
+    public function withUri(UriInterface $uri, $preserveHost = false): ServerRequestInterface
     {
         $serverRequest = $this->serverRequest->withUri($uri, $preserveHost);
 
@@ -177,7 +178,7 @@ class ServerRequest implements ServerRequestInterface
     /**
      * @inheritDoc
      */
-    public function getServerParams()
+    public function getServerParams(): array
     {
         return $this->serverRequest->getServerParams();
     }
@@ -185,7 +186,7 @@ class ServerRequest implements ServerRequestInterface
     /**
      * @inheritDoc
      */
-    public function getCookieParams()
+    public function getCookieParams(): array
     {
         return $this->serverRequest->getCookieParams();
     }
@@ -193,7 +194,7 @@ class ServerRequest implements ServerRequestInterface
     /**
      * @inheritDoc
      */
-    public function withCookieParams(array $cookies)
+    public function withCookieParams(array $cookies): ServerRequestInterface
     {
         $serverRequest = $this->serverRequest->withCookieParams($cookies);
 
@@ -203,7 +204,7 @@ class ServerRequest implements ServerRequestInterface
     /**
      * @inheritDoc
      */
-    public function getQueryParams()
+    public function getQueryParams(): array
     {
         return $this->serverRequest->getQueryParams();
     }
@@ -211,7 +212,7 @@ class ServerRequest implements ServerRequestInterface
     /**
      * @inheritDoc
      */
-    public function withQueryParams(array $query)
+    public function withQueryParams(array $query): ServerRequestInterface
     {
         $serverRequest = $this->serverRequest->withQueryParams($query);
 
@@ -221,7 +222,7 @@ class ServerRequest implements ServerRequestInterface
     /**
      * @inheritDoc
      */
-    public function getUploadedFiles()
+    public function getUploadedFiles(): array
     {
         return $this->serverRequest->getUploadedFiles();
     }
@@ -229,7 +230,7 @@ class ServerRequest implements ServerRequestInterface
     /**
      * @inheritDoc
      */
-    public function withUploadedFiles(array $uploadedFiles)
+    public function withUploadedFiles(array $uploadedFiles): ServerRequestInterface
     {
         $serverRequest = $this->serverRequest->withUploadedFiles($uploadedFiles);
 
@@ -247,7 +248,7 @@ class ServerRequest implements ServerRequestInterface
     /**
      * @inheritDoc
      */
-    public function withParsedBody($data)
+    public function withParsedBody($data): ServerRequestInterface
     {
         $serverRequest = $this->serverRequest->withParsedBody($data);
 
@@ -257,7 +258,7 @@ class ServerRequest implements ServerRequestInterface
     /**
      * @inheritDoc
      */
-    public function getAttributes()
+    public function getAttributes(): array
     {
         return $this->serverRequest->getAttributes();
     }
@@ -273,7 +274,7 @@ class ServerRequest implements ServerRequestInterface
     /**
      * @inheritDoc
      */
-    public function withAttribute($name, $value)
+    public function withAttribute($name, $value): ServerRequestInterface
     {
         $serverRequest = $this->serverRequest->withAttribute($name, $value);
 
@@ -283,7 +284,7 @@ class ServerRequest implements ServerRequestInterface
     /**
      * @inheritDoc
      */
-    public function withoutAttribute($name)
+    public function withoutAttribute(string $name): ServerRequestInterface
     {
         $serverRequest = $this->serverRequest->withoutAttribute($name);
 
