Skip to content

Commit ecea361

Browse files
committed
Minor cleanup
1 parent f9f44c6 commit ecea361

File tree

2 files changed

+8
-13
lines changed

2 files changed

+8
-13
lines changed

src/Deferred.php

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,10 @@
1414
final class Deferred implements Promise
1515
{
1616
private $value;
17-
1817
private $failure;
19-
2018
private $state;
21-
2219
private $waitCallback;
23-
2420
private $onFulfilledCallbacks;
25-
2621
private $onRejectedCallbacks;
2722

2823
public function __construct(callable $waitCallback)
@@ -81,12 +76,12 @@ public function getState(): string
8176
*/
8277
public function resolve(ResponseInterface $response): void
8378
{
84-
if (self::PENDING !== $this->state) {
79+
if (Promise::PENDING !== $this->state) {
8580
return;
8681
}
8782

8883
$this->value = $response;
89-
$this->state = self::FULFILLED;
84+
$this->state = Promise::FULFILLED;
9085

9186
foreach ($this->onFulfilledCallbacks as $onFulfilledCallback) {
9287
$onFulfilledCallback($response);
@@ -98,12 +93,12 @@ public function resolve(ResponseInterface $response): void
9893
*/
9994
public function reject(Exception $exception): void
10095
{
101-
if (self::PENDING !== $this->state) {
96+
if (Promise::PENDING !== $this->state) {
10297
return;
10398
}
10499

105100
$this->failure = $exception;
106-
$this->state = self::REJECTED;
101+
$this->state = Promise::REJECTED;
107102

108103
foreach ($this->onRejectedCallbacks as $onRejectedCallback) {
109104
$onRejectedCallback($exception);
@@ -115,16 +110,16 @@ public function reject(Exception $exception): void
115110
*/
116111
public function wait($unwrap = true)
117112
{
118-
if (self::PENDING === $this->state) {
113+
if (Promise::PENDING === $this->state) {
119114
$callback = $this->waitCallback;
120115
$callback();
121116
}
122117

123118
if (!$unwrap) {
124-
return;
119+
return null;
125120
}
126121

127-
if (self::FULFILLED === $this->state) {
122+
if (Promise::FULFILLED === $this->state) {
128123
return $this->value;
129124
}
130125

src/HttpClientPool/HttpClientPoolItem.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ class HttpClientPoolItem implements HttpClient, HttpAsyncClient
5757
* @param ClientInterface|HttpAsyncClient $client
5858
* @param null|int $reenableAfter Number of seconds until this client is enabled again after an error
5959
*/
60-
public function __construct($client, $reenableAfter = null)
60+
public function __construct($client, int $reenableAfter = null)
6161
{
6262
$this->client = new FlexibleHttpClient($client);
6363
$this->reenableAfter = $reenableAfter;

0 commit comments

Comments
 (0)