Skip to content

Commit 421bb9b

Browse files
committed
Clean up event loop left overs from promise
I somehow missed those while working on #50
1 parent 99bd0fa commit 421bb9b

File tree

3 files changed

+4
-20
lines changed

3 files changed

+4
-20
lines changed

src/Client.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,6 @@ public function sendAsyncRequest(RequestInterface $request)
6969
$request->getHeaders(),
7070
$request->getBody()
7171
),
72-
$this->loop,
7372
$request
7473
);
7574

src/Promise.php

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -58,19 +58,11 @@ final class Promise implements HttpPromise
5858
*/
5959
private $promise;
6060

61-
/**
62-
* ReactPHP LoopInterface.
63-
*
64-
* @var LoopInterface
65-
*/
66-
private $loop;
67-
68-
public function __construct(PromiseInterface $promise, LoopInterface $loop, RequestInterface $request)
61+
public function __construct(PromiseInterface $promise, RequestInterface $request)
6962
{
7063
$this->state = self::PENDING;
7164

7265
$this->request = $request;
73-
$this->loop = $loop;
7466
$this->promise = $promise->then(
7567
function (?ResponseInterface $response): ?ResponseInterface {
7668
$this->response = $response;
@@ -101,7 +93,7 @@ function ($reason): void {
10193

10294
public function then(?callable $onFulfilled = null, ?callable $onRejected = null)
10395
{
104-
return new self($this->promise->then($onFulfilled, $onRejected), $this->loop, $this->request);
96+
return new self($this->promise->then($onFulfilled, $onRejected), $this->request);
10597
}
10698

10799
/**

tests/PromiseTest.php

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,6 @@
1818

1919
class PromiseTest extends TestCase
2020
{
21-
private $loop;
22-
23-
public function setUp(): void
24-
{
25-
$this->loop = ReactFactory::buildEventLoop();
26-
}
27-
2821
public function testChain()
2922
{
3023
$factory = new Psr17Factory();
@@ -35,7 +28,7 @@ public function testChain()
3528
$resolve($response);
3629
});
3730

38-
$promise = new Promise($reactPromise, $this->loop, $request);
31+
$promise = new Promise($reactPromise, $request);
3932

4033
$lastPromise = $promise->then(function (ResponseInterface $response) use ($factory) {
4134
return $factory->createResponse(300, $response->getReasonPhrase());
@@ -60,7 +53,7 @@ public function testPromiseExceptionsAreTranslatedToHttplug(
6053
$reject($reason);
6154
});
6255

63-
$promise = new Promise($reactPromise, $this->loop, $request);
56+
$promise = new Promise($reactPromise, $request);
6457
$this->expectException($adapterExceptionClass);
6558
$promise->wait();
6659
}

0 commit comments

Comments
 (0)