From 544408d0fa948da15f3d64cb2ac2e93f167dbf74 Mon Sep 17 00:00:00 2001 From: Simon Podlipsky Date: Mon, 22 Nov 2021 14:33:36 +0100 Subject: [PATCH] Make PromiseInterface generic so it allows typing Promises --- .../src/Adapter/GuzzleHttpPromiseAdapter.php | 3 +++ .../src/Adapter/ReactPromiseAdapter.php | 3 +++ .../WebonyxGraphQLSyncPromiseAdapter.php | 3 +++ .../src/PromiseAdapterInterface.php | 17 ++++++++++------- 4 files changed, 19 insertions(+), 7 deletions(-) diff --git a/lib/promise-adapter/src/Adapter/GuzzleHttpPromiseAdapter.php b/lib/promise-adapter/src/Adapter/GuzzleHttpPromiseAdapter.php index def124e..46d9ba6 100644 --- a/lib/promise-adapter/src/Adapter/GuzzleHttpPromiseAdapter.php +++ b/lib/promise-adapter/src/Adapter/GuzzleHttpPromiseAdapter.php @@ -17,6 +17,9 @@ use GuzzleHttp\Promise\RejectedPromise; use Overblog\PromiseAdapter\PromiseAdapterInterface; +/** + * @implements PromiseAdapterInterface + */ class GuzzleHttpPromiseAdapter implements PromiseAdapterInterface { /** diff --git a/lib/promise-adapter/src/Adapter/ReactPromiseAdapter.php b/lib/promise-adapter/src/Adapter/ReactPromiseAdapter.php index 545e55f..5be2069 100644 --- a/lib/promise-adapter/src/Adapter/ReactPromiseAdapter.php +++ b/lib/promise-adapter/src/Adapter/ReactPromiseAdapter.php @@ -19,6 +19,9 @@ use React\Promise\PromiseInterface; use React\Promise\RejectedPromise; +/** + * @implements PromiseAdapterInterface + */ class ReactPromiseAdapter implements PromiseAdapterInterface { /** diff --git a/lib/promise-adapter/src/Adapter/WebonyxGraphQLSyncPromiseAdapter.php b/lib/promise-adapter/src/Adapter/WebonyxGraphQLSyncPromiseAdapter.php index 6245a92..664ffe5 100644 --- a/lib/promise-adapter/src/Adapter/WebonyxGraphQLSyncPromiseAdapter.php +++ b/lib/promise-adapter/src/Adapter/WebonyxGraphQLSyncPromiseAdapter.php @@ -17,6 +17,9 @@ use GraphQL\Executor\Promise\Promise; use Overblog\PromiseAdapter\PromiseAdapterInterface; +/** + * @implements PromiseAdapterInterface + */ class WebonyxGraphQLSyncPromiseAdapter implements PromiseAdapterInterface { /** @var callable[] */ diff --git a/lib/promise-adapter/src/PromiseAdapterInterface.php b/lib/promise-adapter/src/PromiseAdapterInterface.php index ea28744..cf67a01 100644 --- a/lib/promise-adapter/src/PromiseAdapterInterface.php +++ b/lib/promise-adapter/src/PromiseAdapterInterface.php @@ -11,6 +11,9 @@ namespace Overblog\PromiseAdapter; +/** + * @template TPromise + */ interface PromiseAdapterInterface { /** @@ -20,7 +23,7 @@ interface PromiseAdapterInterface * @param $reject * @param callable $canceller * - * @return mixed a Promise + * @return TPromise a Promise */ public function create(&$resolve = null, &$reject = null, callable $canceller = null); @@ -29,7 +32,7 @@ public function create(&$resolve = null, &$reject = null, callable $canceller = * * @param mixed $promiseOrValue * - * @return mixed a full filed Promise + * @return TPromise a full filed Promise */ public function createFulfilled($promiseOrValue = null); @@ -39,7 +42,7 @@ public function createFulfilled($promiseOrValue = null); * * @param mixed $reason * - * @return mixed a rejected promise + * @return TPromise a rejected promise */ public function createRejected($reason); @@ -49,7 +52,7 @@ public function createRejected($reason); * * @param mixed $promisesOrValues Promises or values. * - * @return mixed a Promise + * @return TPromise a Promise */ public function createAll($promisesOrValues); @@ -66,14 +69,14 @@ public function isPromise($value, $strict = false); /** * Cancel a promise * - * @param $promise + * @param TPromise $promise */ public function cancel($promise); /** * wait for Promise to complete - * @param mixed $promise - * @param bool $unwrap + * @param TPromise $promise + * @param bool $unwrap * * @return mixed */