Skip to content

Commit b355935

Browse files
authored
Merge pull request #213 from clue-labs/resolve-argument
Require argument for `resolve()` function
2 parents 16a338b + 89fab35 commit b355935

13 files changed

+26
-27
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ $deferred = new React\Promise\Deferred();
9696

9797
$promise = $deferred->promise();
9898

99-
$deferred->resolve(mixed $value = null);
99+
$deferred->resolve(mixed $value);
100100
$deferred->reject(\Throwable $reason);
101101
```
102102

@@ -119,7 +119,7 @@ keeping the authority to modify its state to yourself.
119119
#### Deferred::resolve()
120120

121121
```php
122-
$deferred->resolve(mixed $value = null);
122+
$deferred->resolve(mixed $value);
123123
```
124124

125125
Resolves the promise returned by `promise()`. All consumers are notified by

src/Deferred.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ public function promise(): PromiseInterface
2121
return $this->promise;
2222
}
2323

24-
public function resolve($value = null): void
24+
public function resolve($value): void
2525
{
2626
($this->resolveCallback)($value);
2727
}

src/Promise.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,7 @@ private function call(callable $cb): void
239239
$target =& $this;
240240

241241
$callback(
242-
static function ($value = null) use (&$target) {
242+
static function ($value) use (&$target) {
243243
if ($target !== null) {
244244
$target->settle(resolve($value));
245245
$target = null;

src/functions.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,7 @@
2020
* @param mixed $promiseOrValue
2121
* @return PromiseInterface
2222
*/
23-
24-
function resolve($promiseOrValue = null): PromiseInterface
23+
function resolve($promiseOrValue): PromiseInterface
2524
{
2625
if ($promiseOrValue instanceof PromiseInterface) {
2726
return $promiseOrValue;
@@ -346,7 +345,7 @@ function _checkTypehint(callable $callback, \Throwable $reason): bool
346345

347346
// Extract the type of the argument and handle different possibilities
348347
$type = $expectedException->getType();
349-
348+
350349
$isTypeUnion = true;
351350
$types = [];
352351

tests/FunctionAnyTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ public function shouldCancelInputArrayPromises()
122122
public function shouldNotCancelOtherPendingInputArrayPromisesIfOnePromiseFulfills()
123123
{
124124
$deferred = new Deferred($this->expectCallableNever());
125-
$deferred->resolve();
125+
$deferred->resolve(null);
126126

127127
$promise2 = new Promise(function () {}, $this->expectCallableNever());
128128

tests/FunctionRaceTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ public function shouldCancelInputArrayPromises()
103103
public function shouldNotCancelOtherPendingInputArrayPromisesIfOnePromiseFulfills()
104104
{
105105
$deferred = new Deferred($this->expectCallableNever());
106-
$deferred->resolve();
106+
$deferred->resolve(null);
107107

108108
$promise2 = new Promise(function () {}, $this->expectCallableNever());
109109

tests/FunctionSomeTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ public function shouldCancelInputArrayPromises()
148148
public function shouldCancelOtherPendingInputArrayPromisesIfEnoughPromisesFulfill()
149149
{
150150
$deferred = new Deferred($this->expectCallableNever());
151-
$deferred->resolve();
151+
$deferred->resolve(null);
152152

153153
$promise2 = new Promise(function () {}, $this->expectCallableNever());
154154

tests/PromiseTest/CancelTestTrait.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ public function cancelShouldCallCancellerOnlyOnceIfCancellerResolves()
110110
->expects($this->once())
111111
->method('__invoke')
112112
->will($this->returnCallback(function ($resolve) {
113-
$resolve();
113+
$resolve(null);
114114
}));
115115

116116
$adapter = $this->getPromiseTestAdapter($mock);

tests/PromiseTest/PromiseFulfilledTestTrait.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ public function cancelShouldReturnNullForFulfilledPromise()
190190
{
191191
$adapter = $this->getPromiseTestAdapter();
192192

193-
$adapter->resolve();
193+
$adapter->resolve(null);
194194

195195
self::assertNull($adapter->promise()->cancel());
196196
}
@@ -200,7 +200,7 @@ public function cancelShouldHaveNoEffectForFulfilledPromise()
200200
{
201201
$adapter = $this->getPromiseTestAdapter($this->expectCallableNever());
202202

203-
$adapter->resolve();
203+
$adapter->resolve(null);
204204

205205
$adapter->promise()->cancel();
206206
}

tests/PromiseTest/PromisePendingTestTrait.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ public function catchShouldNotInvokeRejectionHandlerForPendingPromise()
5757
{
5858
$adapter = $this->getPromiseTestAdapter();
5959

60-
$adapter->settle();
60+
$adapter->settle(null);
6161
$adapter->promise()->catch($this->expectCallableNever());
6262
}
6363

@@ -77,7 +77,7 @@ public function otherwiseShouldNotInvokeRejectionHandlerForPendingPromise()
7777
{
7878
$adapter = $this->getPromiseTestAdapter();
7979

80-
$adapter->settle();
80+
$adapter->settle(null);
8181
$adapter->promise()->otherwise($this->expectCallableNever());
8282
}
8383

0 commit comments

Comments
 (0)