diff --git a/src/DataLoader.php b/src/DataLoader.php index 7cd10a3..f2236e2 100644 --- a/src/DataLoader.php +++ b/src/DataLoader.php @@ -13,6 +13,11 @@ use Overblog\PromiseAdapter\PromiseAdapterInterface; +/** + * @template TPromise + * + * @implements DataLoaderInterface + */ class DataLoader implements DataLoaderInterface { /** @@ -51,10 +56,13 @@ class DataLoader implements DataLoaderInterface private static $promiseAdapters; /** - * @var PromiseAdapterInterface + * @var PromiseAdapterInterface */ private $promiseAdapter; + /** + * @param PromiseAdapterInterface $promiseFactory + */ public function __construct(callable $batchLoadFn, PromiseAdapterInterface $promiseFactory, ?Option $options = null) { $this->batchLoadFn = $batchLoadFn; @@ -65,9 +73,7 @@ public function __construct(callable $batchLoadFn, PromiseAdapterInterface $prom self::$instances[$this] = null; } - /** - * {@inheritdoc} - */ + /** @return TPromise */ public function load($key) { $this->checkKey($key, __METHOD__); @@ -122,9 +128,7 @@ static function () { return $promise; } - /** - * {@inheritdoc} - */ + /** @return TPromise */ public function loadMany($keys) { if (!is_array($keys) && !$keys instanceof \Traversable) { @@ -219,6 +223,7 @@ protected function process() } } + /** @return PromiseAdapterInterface */ protected function getPromiseAdapter() { return $this->promiseAdapter; diff --git a/src/DataLoaderInterface.php b/src/DataLoaderInterface.php index 4c77745..6bbe513 100644 --- a/src/DataLoaderInterface.php +++ b/src/DataLoaderInterface.php @@ -11,6 +11,9 @@ namespace Overblog\DataLoader; +/** + * @template TPromise + */ interface DataLoaderInterface { /** @@ -18,7 +21,7 @@ interface DataLoaderInterface * * @param mixed $key * - * @return mixed return a Promise + * @return TPromise a Promise */ public function load($key); @@ -35,7 +38,7 @@ public function load($key); * ]); * @param array $keys * - * @return mixed return a Promise + * @return TPromise a Promise */ public function loadMany($keys);