Skip to content

Commit 9102fe2

Browse files
committed
Use Promise v3 template types
1 parent 7c3738e commit 9102fe2

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

src/functions.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,7 @@
189189
*/
190190
function async(callable $function): callable
191191
{
192+
/** @var callable(A1=,A2=,A3=,A4=,A5=): PromiseInterface<T> */
192193
return static function (mixed ...$args) use ($function): PromiseInterface {
193194
$fiber = null;
194195
$promise = new Promise(function (callable $resolve, callable $reject) use ($function, $args, &$fiber): void {
@@ -673,6 +674,7 @@ function coroutine(callable $function, mixed ...$args): PromiseInterface
673674
};
674675
$next();
675676

677+
/** @var PromiseInterface<T> */
676678
return $deferred->promise();
677679
}
678680

@@ -734,6 +736,7 @@ function parallel(iterable $tasks): PromiseInterface
734736
$deferred->resolve($results);
735737
}
736738

739+
/** @var PromiseInterface<array<T>> */
737740
return $deferred->promise();
738741
}
739742

@@ -789,6 +792,7 @@ function series(iterable $tasks): PromiseInterface
789792

790793
$next();
791794

795+
/** @var PromiseInterface<array<T>> */
792796
return $deferred->promise();
793797
}
794798

@@ -838,5 +842,6 @@ function waterfall(iterable $tasks): PromiseInterface
838842

839843
$next();
840844

845+
/** @var PromiseInterface<T> */
841846
return $deferred->promise();
842847
}

tests/AwaitTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ public function testAwaitThrowsUnexpectedValueExceptionWhenPromiseIsRejectedWith
129129
}
130130

131131
$promise = new Promise(function ($_, $reject) {
132-
$reject(false);
132+
$reject(false); // @phpstan-ignore-line
133133
});
134134

135135
$this->expectException(\UnexpectedValueException::class);
@@ -147,7 +147,7 @@ public function testAwaitThrowsUnexpectedValueExceptionWhenPromiseIsRejectedWith
147147
}
148148

149149
$promise = new Promise(function ($_, $reject) {
150-
$reject(null);
150+
$reject(null); // @phpstan-ignore-line
151151
});
152152

153153
try {
@@ -331,7 +331,7 @@ public function testAwaitShouldNotCreateAnyGarbageReferencesForPromiseRejectedWi
331331
gc_collect_cycles();
332332

333333
$promise = new Promise(function ($_, $reject) {
334-
$reject(null);
334+
$reject(null); // @phpstan-ignore-line
335335
});
336336
try {
337337
$await($promise);

0 commit comments

Comments
 (0)