Skip to content

Commit

Permalink
Merge pull request #57 from simPod/generic-interface
Browse files Browse the repository at this point in the history
Make PromiseInterface generic so it allows typing Promises
  • Loading branch information
mcg-web authored Nov 22, 2021
2 parents 56ca285 + 544408d commit 9181113
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 7 deletions.
3 changes: 3 additions & 0 deletions lib/promise-adapter/src/Adapter/GuzzleHttpPromiseAdapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@
use GuzzleHttp\Promise\RejectedPromise;
use Overblog\PromiseAdapter\PromiseAdapterInterface;

/**
* @implements PromiseAdapterInterface<PromiseInterface>
*/
class GuzzleHttpPromiseAdapter implements PromiseAdapterInterface
{
/**
Expand Down
3 changes: 3 additions & 0 deletions lib/promise-adapter/src/Adapter/ReactPromiseAdapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@
use React\Promise\PromiseInterface;
use React\Promise\RejectedPromise;

/**
* @implements PromiseAdapterInterface<Promise>
*/
class ReactPromiseAdapter implements PromiseAdapterInterface
{
/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@
use GraphQL\Executor\Promise\Promise;
use Overblog\PromiseAdapter\PromiseAdapterInterface;

/**
* @implements PromiseAdapterInterface<Promise>
*/
class WebonyxGraphQLSyncPromiseAdapter implements PromiseAdapterInterface
{
/** @var callable[] */
Expand Down
17 changes: 10 additions & 7 deletions lib/promise-adapter/src/PromiseAdapterInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@

namespace Overblog\PromiseAdapter;

/**
* @template TPromise
*/
interface PromiseAdapterInterface
{
/**
Expand All @@ -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);

Expand All @@ -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);

Expand All @@ -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);

Expand All @@ -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);

Expand All @@ -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
*/
Expand Down

0 comments on commit 9181113

Please sign in to comment.