-
-
Notifications
You must be signed in to change notification settings - Fork 19
Expand file tree
/
Copy pathseries.php
More file actions
35 lines (29 loc) · 1.14 KB
/
series.php
File metadata and controls
35 lines (29 loc) · 1.14 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
<?php
use React\Promise\PromiseInterface;
use function PHPStan\Testing\assertType;
use function React\Async\await;
use function React\Async\series;
use function React\Promise\resolve;
/** @var array<callable():mixed> $emptyArray */
$emptyArray = [];
assertType('React\Promise\PromiseInterface<array>', series($emptyArray));
assertType('React\Promise\PromiseInterface<array<bool|float|int>>', series([
static fn (): PromiseInterface => resolve(true),
static fn (): PromiseInterface => resolve(time()),
static fn (): PromiseInterface => resolve(microtime(true)),
]));
assertType('React\Promise\PromiseInterface<array<bool|float|int>>', series([
static fn (): bool => true,
static fn (): int => time(),
static fn (): float => microtime(true),
]));
assertType('array<bool|float|int>', await(series([
static fn (): PromiseInterface => resolve(true),
static fn (): PromiseInterface => resolve(time()),
static fn (): PromiseInterface => resolve(microtime(true)),
])));
assertType('array<bool|float|int>', await(series([
static fn (): bool => true,
static fn (): int => time(),
static fn (): float => microtime(true),
])));