19
19
use Discord \Http \Exceptions \NotFoundException ;
20
20
use Discord \Http \Exceptions \RateLimitException ;
21
21
use Discord \Http \Exceptions \RequestFailedException ;
22
+ use Discord \Http \PromiseHelpers \Deferred ;
22
23
use Discord \Http \Multipart \MultipartBody ;
23
24
use Psr \Http \Message \ResponseInterface ;
24
25
use Psr \Log \LoggerInterface ;
25
26
use React \EventLoop \LoopInterface ;
26
- use React \Promise \Deferred ;
27
- use React \Promise \ExtendedPromiseInterface ;
27
+ use React \Promise \PromiseInterface ;
28
28
use SplQueue ;
29
29
30
30
/**
@@ -39,7 +39,7 @@ class Http
39
39
*
40
40
* @var string
41
41
*/
42
- public const VERSION = 'v10.3 .0 ' ;
42
+ public const VERSION = 'v10.4 .0 ' ;
43
43
44
44
/**
45
45
* Current Discord HTTP API version.
@@ -160,9 +160,9 @@ public function setDriver(DriverInterface $driver): void
160
160
* @param mixed $content
161
161
* @param array $headers
162
162
*
163
- * @return ExtendedPromiseInterface
163
+ * @return \Discord\Http\PromiseHelpers\PolyFillPromiseInterface|\React\Promise\ ExtendedPromiseInterface
164
164
*/
165
- public function get ($ url , $ content = null , array $ headers = []): ExtendedPromiseInterface
165
+ public function get ($ url , $ content = null , array $ headers = []): PromiseInterface
166
166
{
167
167
if (! ($ url instanceof Endpoint)) {
168
168
$ url = Endpoint::bind ($ url );
@@ -178,9 +178,9 @@ public function get($url, $content = null, array $headers = []): ExtendedPromise
178
178
* @param mixed $content
179
179
* @param array $headers
180
180
*
181
- * @return ExtendedPromiseInterface
181
+ * @return \Discord\Http\PromiseHelpers\PolyFillPromiseInterface|\React\Promise\ ExtendedPromiseInterface
182
182
*/
183
- public function post ($ url , $ content = null , array $ headers = []): ExtendedPromiseInterface
183
+ public function post ($ url , $ content = null , array $ headers = []): PromiseInterface
184
184
{
185
185
if (! ($ url instanceof Endpoint)) {
186
186
$ url = Endpoint::bind ($ url );
@@ -196,9 +196,9 @@ public function post($url, $content = null, array $headers = []): ExtendedPromis
196
196
* @param mixed $content
197
197
* @param array $headers
198
198
*
199
- * @return ExtendedPromiseInterface
199
+ * @return \Discord\Http\PromiseHelpers\PolyFillPromiseInterface|\React\Promise\ ExtendedPromiseInterface
200
200
*/
201
- public function put ($ url , $ content = null , array $ headers = []): ExtendedPromiseInterface
201
+ public function put ($ url , $ content = null , array $ headers = []): PromiseInterface
202
202
{
203
203
if (! ($ url instanceof Endpoint)) {
204
204
$ url = Endpoint::bind ($ url );
@@ -214,9 +214,9 @@ public function put($url, $content = null, array $headers = []): ExtendedPromise
214
214
* @param mixed $content
215
215
* @param array $headers
216
216
*
217
- * @return ExtendedPromiseInterface
217
+ * @return \Discord\Http\PromiseHelpers\PolyFillPromiseInterface|\React\Promise\ ExtendedPromiseInterface
218
218
*/
219
- public function patch ($ url , $ content = null , array $ headers = []): ExtendedPromiseInterface
219
+ public function patch ($ url , $ content = null , array $ headers = []): PromiseInterface
220
220
{
221
221
if (! ($ url instanceof Endpoint)) {
222
222
$ url = Endpoint::bind ($ url );
@@ -232,9 +232,9 @@ public function patch($url, $content = null, array $headers = []): ExtendedPromi
232
232
* @param mixed $content
233
233
* @param array $headers
234
234
*
235
- * @return ExtendedPromiseInterface
235
+ * @return \Discord\Http\PromiseHelpers\PolyFillPromiseInterface|\React\Promise\ ExtendedPromiseInterface
236
236
*/
237
- public function delete ($ url , $ content = null , array $ headers = []): ExtendedPromiseInterface
237
+ public function delete ($ url , $ content = null , array $ headers = []): PromiseInterface
238
238
{
239
239
if (! ($ url instanceof Endpoint)) {
240
240
$ url = Endpoint::bind ($ url );
@@ -251,9 +251,9 @@ public function delete($url, $content = null, array $headers = []): ExtendedProm
251
251
* @param mixed $content
252
252
* @param array $headers
253
253
*
254
- * @return ExtendedPromiseInterface
254
+ * @return \Discord\Http\PromiseHelpers\PolyFillPromiseInterface|\React\Promise\ ExtendedPromiseInterface
255
255
*/
256
- public function queueRequest (string $ method , Endpoint $ url , $ content , array $ headers = []): ExtendedPromiseInterface
256
+ public function queueRequest (string $ method , Endpoint $ url , $ content , array $ headers = []): PromiseInterface
257
257
{
258
258
$ deferred = new Deferred ();
259
259
@@ -318,16 +318,16 @@ protected function guessContent(&$content)
318
318
* @param Request $request
319
319
* @param Deferred $deferred
320
320
*
321
- * @return ExtendedPromiseInterface
321
+ * @return \Discord\Http\PromiseHelpers\PolyFillPromiseInterface|\React\Promise\ ExtendedPromiseInterface
322
322
*/
323
- protected function executeRequest (Request $ request , Deferred $ deferred = null ): ExtendedPromiseInterface
323
+ protected function executeRequest (Request $ request , Deferred $ deferred = null ): PromiseInterface
324
324
{
325
325
if ($ deferred === null ) {
326
326
$ deferred = new Deferred ();
327
327
}
328
328
329
329
if ($ this ->rateLimit ) {
330
- $ deferred ->reject ($ this ->rateLimit );
330
+ $ deferred ->reject ($ this ->rateLimit ); // TODO handle resolve ratelimit
331
331
332
332
return $ deferred ->promise ();
333
333
}
@@ -383,7 +383,7 @@ protected function executeRequest(Request $request, Deferred $deferred = null):
383
383
});
384
384
}
385
385
386
- $ deferred ->reject ($ rateLimit ->isGlobal () ? $ this ->rateLimit : $ rateLimit );
386
+ $ deferred ->reject ($ rateLimit ->isGlobal () ? $ this ->rateLimit : $ rateLimit ); // TODO handle resolve ratelimit
387
387
}
388
388
// Bad Gateway
389
389
// Cloudflare SSL Handshake error
@@ -476,7 +476,7 @@ protected function checkQueue(): void
476
476
--$ this ->waiting ;
477
477
$ this ->checkQueue ();
478
478
$ deferred ->resolve ($ result );
479
- }, function ($ e ) use ($ deferred ) {
479
+ }, function ($ e ) use ($ deferred ) { // TODO handle resolve reject
480
480
--$ this ->waiting ;
481
481
$ this ->checkQueue ();
482
482
$ deferred ->reject ($ e );
0 commit comments