1919use Discord \Http \Exceptions \NotFoundException ;
2020use Discord \Http \Exceptions \RateLimitException ;
2121use Discord \Http \Exceptions \RequestFailedException ;
22+ use Discord \Http \PromiseHelpers \Deferred ;
2223use Discord \Http \Multipart \MultipartBody ;
2324use Psr \Http \Message \ResponseInterface ;
2425use Psr \Log \LoggerInterface ;
2526use React \EventLoop \LoopInterface ;
26- use React \Promise \Deferred ;
27- use React \Promise \ExtendedPromiseInterface ;
27+ use React \Promise \PromiseInterface ;
2828use SplQueue ;
2929
3030/**
@@ -39,7 +39,7 @@ class Http
3939 *
4040 * @var string
4141 */
42- public const VERSION = 'v10.3 .0 ' ;
42+ public const VERSION = 'v10.4 .0 ' ;
4343
4444 /**
4545 * Current Discord HTTP API version.
@@ -160,9 +160,9 @@ public function setDriver(DriverInterface $driver): void
160160 * @param mixed $content
161161 * @param array $headers
162162 *
163- * @return ExtendedPromiseInterface
163+ * @return \Discord\Http\PromiseHelpers\PolyFillPromiseInterface|\React\Promise\ ExtendedPromiseInterface
164164 */
165- public function get ($ url , $ content = null , array $ headers = []): ExtendedPromiseInterface
165+ public function get ($ url , $ content = null , array $ headers = []): PromiseInterface
166166 {
167167 if (! ($ url instanceof Endpoint)) {
168168 $ url = Endpoint::bind ($ url );
@@ -178,9 +178,9 @@ public function get($url, $content = null, array $headers = []): ExtendedPromise
178178 * @param mixed $content
179179 * @param array $headers
180180 *
181- * @return ExtendedPromiseInterface
181+ * @return \Discord\Http\PromiseHelpers\PolyFillPromiseInterface|\React\Promise\ ExtendedPromiseInterface
182182 */
183- public function post ($ url , $ content = null , array $ headers = []): ExtendedPromiseInterface
183+ public function post ($ url , $ content = null , array $ headers = []): PromiseInterface
184184 {
185185 if (! ($ url instanceof Endpoint)) {
186186 $ url = Endpoint::bind ($ url );
@@ -196,9 +196,9 @@ public function post($url, $content = null, array $headers = []): ExtendedPromis
196196 * @param mixed $content
197197 * @param array $headers
198198 *
199- * @return ExtendedPromiseInterface
199+ * @return \Discord\Http\PromiseHelpers\PolyFillPromiseInterface|\React\Promise\ ExtendedPromiseInterface
200200 */
201- public function put ($ url , $ content = null , array $ headers = []): ExtendedPromiseInterface
201+ public function put ($ url , $ content = null , array $ headers = []): PromiseInterface
202202 {
203203 if (! ($ url instanceof Endpoint)) {
204204 $ url = Endpoint::bind ($ url );
@@ -214,9 +214,9 @@ public function put($url, $content = null, array $headers = []): ExtendedPromise
214214 * @param mixed $content
215215 * @param array $headers
216216 *
217- * @return ExtendedPromiseInterface
217+ * @return \Discord\Http\PromiseHelpers\PolyFillPromiseInterface|\React\Promise\ ExtendedPromiseInterface
218218 */
219- public function patch ($ url , $ content = null , array $ headers = []): ExtendedPromiseInterface
219+ public function patch ($ url , $ content = null , array $ headers = []): PromiseInterface
220220 {
221221 if (! ($ url instanceof Endpoint)) {
222222 $ url = Endpoint::bind ($ url );
@@ -232,9 +232,9 @@ public function patch($url, $content = null, array $headers = []): ExtendedPromi
232232 * @param mixed $content
233233 * @param array $headers
234234 *
235- * @return ExtendedPromiseInterface
235+ * @return \Discord\Http\PromiseHelpers\PolyFillPromiseInterface|\React\Promise\ ExtendedPromiseInterface
236236 */
237- public function delete ($ url , $ content = null , array $ headers = []): ExtendedPromiseInterface
237+ public function delete ($ url , $ content = null , array $ headers = []): PromiseInterface
238238 {
239239 if (! ($ url instanceof Endpoint)) {
240240 $ url = Endpoint::bind ($ url );
@@ -251,9 +251,9 @@ public function delete($url, $content = null, array $headers = []): ExtendedProm
251251 * @param mixed $content
252252 * @param array $headers
253253 *
254- * @return ExtendedPromiseInterface
254+ * @return \Discord\Http\PromiseHelpers\PolyFillPromiseInterface|\React\Promise\ ExtendedPromiseInterface
255255 */
256- public function queueRequest (string $ method , Endpoint $ url , $ content , array $ headers = []): ExtendedPromiseInterface
256+ public function queueRequest (string $ method , Endpoint $ url , $ content , array $ headers = []): PromiseInterface
257257 {
258258 $ deferred = new Deferred ();
259259
@@ -318,16 +318,16 @@ protected function guessContent(&$content)
318318 * @param Request $request
319319 * @param Deferred $deferred
320320 *
321- * @return ExtendedPromiseInterface
321+ * @return \Discord\Http\PromiseHelpers\PolyFillPromiseInterface|\React\Promise\ ExtendedPromiseInterface
322322 */
323- protected function executeRequest (Request $ request , Deferred $ deferred = null ): ExtendedPromiseInterface
323+ protected function executeRequest (Request $ request , Deferred $ deferred = null ): PromiseInterface
324324 {
325325 if ($ deferred === null ) {
326326 $ deferred = new Deferred ();
327327 }
328328
329329 if ($ this ->rateLimit ) {
330- $ deferred ->reject ($ this ->rateLimit );
330+ $ deferred ->reject ($ this ->rateLimit ); // TODO handle resolve ratelimit
331331
332332 return $ deferred ->promise ();
333333 }
@@ -383,7 +383,7 @@ protected function executeRequest(Request $request, Deferred $deferred = null):
383383 });
384384 }
385385
386- $ deferred ->reject ($ rateLimit ->isGlobal () ? $ this ->rateLimit : $ rateLimit );
386+ $ deferred ->reject ($ rateLimit ->isGlobal () ? $ this ->rateLimit : $ rateLimit ); // TODO handle resolve ratelimit
387387 }
388388 // Bad Gateway
389389 // Cloudflare SSL Handshake error
@@ -476,7 +476,7 @@ protected function checkQueue(): void
476476 --$ this ->waiting ;
477477 $ this ->checkQueue ();
478478 $ deferred ->resolve ($ result );
479- }, function ($ e ) use ($ deferred ) {
479+ }, function ($ e ) use ($ deferred ) { // TODO handle resolve reject
480480 --$ this ->waiting ;
481481 $ this ->checkQueue ();
482482 $ deferred ->reject ($ e );
0 commit comments