From 2acae1af7ae727d6d042133fefe28bf6a27fb6e6 Mon Sep 17 00:00:00 2001
From: David Buchmann <david.buchmann@liip.ch>
Date: Wed, 3 Jan 2024 19:01:02 +0100
Subject: [PATCH] adjust to promise template annotations

---
 .github/workflows/static.yml         |  3 +++
 composer.json                        |  2 +-
 src/Exception/RequestAwareTrait.php  |  3 ---
 src/HttpAsyncClient.php              |  3 ++-
 src/Promise/HttpFulfilledPromise.php | 12 +++---------
 src/Promise/HttpRejectedPromise.php  | 13 ++++---------
 6 files changed, 13 insertions(+), 23 deletions(-)

diff --git a/.github/workflows/static.yml b/.github/workflows/static.yml
index 98c17c1..97903c4 100644
--- a/.github/workflows/static.yml
+++ b/.github/workflows/static.yml
@@ -15,6 +15,9 @@ jobs:
       - name: Checkout code
         uses: actions/checkout@v3
 
+      - name: Remove phpspec
+        run: composer remove phpspec/phpspec
+      
       - name: PHPStan
         uses: docker://oskarstark/phpstan-ga
         with:
diff --git a/composer.json b/composer.json
index 7391770..75f271b 100644
--- a/composer.json
+++ b/composer.json
@@ -20,7 +20,7 @@
     ],
     "require": {
         "php": "^7.1 || ^8.0",
-        "php-http/promise": "^1.1",
+        "php-http/promise": "dev-template-exception as 1.2.2",
         "psr/http-client": "^1.0",
         "psr/http-message": "^1.0 || ^2.0"
     },
diff --git a/src/Exception/RequestAwareTrait.php b/src/Exception/RequestAwareTrait.php
index 71b4bb8..f507982 100644
--- a/src/Exception/RequestAwareTrait.php
+++ b/src/Exception/RequestAwareTrait.php
@@ -16,9 +16,6 @@ private function setRequest(RequestInterface $request)
         $this->request = $request;
     }
 
-    /**
-     * {@inheritdoc}
-     */
     public function getRequest(): RequestInterface
     {
         return $this->request;
diff --git a/src/HttpAsyncClient.php b/src/HttpAsyncClient.php
index c3b9d61..e39d546 100644
--- a/src/HttpAsyncClient.php
+++ b/src/HttpAsyncClient.php
@@ -4,6 +4,7 @@
 
 use Http\Promise\Promise;
 use Psr\Http\Message\RequestInterface;
+use Psr\Http\Message\ResponseInterface;
 
 /**
  * Sends a PSR-7 Request in an asynchronous way by returning a Promise.
@@ -17,7 +18,7 @@ interface HttpAsyncClient
      *
      * Exceptions related to processing the request are available from the returned Promise.
      *
-     * @return Promise resolves a PSR-7 Response or fails with an Http\Client\Exception
+     * @return Promise<ResponseInterface, Exception> resolves a PSR-7 Response or fails with an Http\Client\Exception
      *
      * @throws \Exception If processing the request is impossible (eg. bad configuration).
      */
diff --git a/src/Promise/HttpFulfilledPromise.php b/src/Promise/HttpFulfilledPromise.php
index 1ad32cd..f8c5442 100644
--- a/src/Promise/HttpFulfilledPromise.php
+++ b/src/Promise/HttpFulfilledPromise.php
@@ -6,6 +6,9 @@
 use Http\Promise\Promise;
 use Psr\Http\Message\ResponseInterface;
 
+/**
+ * @implements Promise<ResponseInterface, Exception>
+ */
 final class HttpFulfilledPromise implements Promise
 {
     /**
@@ -18,9 +21,6 @@ public function __construct(ResponseInterface $response)
         $this->response = $response;
     }
 
-    /**
-     * {@inheritdoc}
-     */
     public function then(callable $onFulfilled = null, callable $onRejected = null)
     {
         if (null === $onFulfilled) {
@@ -34,17 +34,11 @@ public function then(callable $onFulfilled = null, callable $onRejected = null)
         }
     }
 
-    /**
-     * {@inheritdoc}
-     */
     public function getState()
     {
         return Promise::FULFILLED;
     }
 
-    /**
-     * {@inheritdoc}
-     */
     public function wait($unwrap = true)
     {
         if ($unwrap) {
diff --git a/src/Promise/HttpRejectedPromise.php b/src/Promise/HttpRejectedPromise.php
index 624cc8a..2b98576 100644
--- a/src/Promise/HttpRejectedPromise.php
+++ b/src/Promise/HttpRejectedPromise.php
@@ -4,7 +4,11 @@
 
 use Http\Client\Exception;
 use Http\Promise\Promise;
+use Psr\Http\Message\ResponseInterface;
 
+/**
+ * @implements Promise<ResponseInterface, Exception>
+ */
 final class HttpRejectedPromise implements Promise
 {
     /**
@@ -17,9 +21,6 @@ public function __construct(Exception $exception)
         $this->exception = $exception;
     }
 
-    /**
-     * {@inheritdoc}
-     */
     public function then(callable $onFulfilled = null, callable $onRejected = null)
     {
         if (null === $onRejected) {
@@ -38,17 +39,11 @@ public function then(callable $onFulfilled = null, callable $onRejected = null)
         }
     }
 
-    /**
-     * {@inheritdoc}
-     */
     public function getState()
     {
         return Promise::REJECTED;
     }
 
-    /**
-     * {@inheritdoc}
-     */
     public function wait($unwrap = true)
     {
         if ($unwrap) {