forked from reactphp/async
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathparallel.php
More file actions
33 lines (27 loc) · 1.26 KB
/
parallel.php
File metadata and controls
33 lines (27 loc) · 1.26 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
<?php
use React\Promise\PromiseInterface;
use function PHPStan\Testing\assertType;
use function React\Async\await;
use function React\Async\parallel;
use function React\Promise\resolve;
assertType('React\Promise\PromiseInterface<array>', parallel([]));
assertType('React\Promise\PromiseInterface<array<bool|float|int>>', parallel([
static function (): PromiseInterface { return resolve(true); },
static function (): PromiseInterface { return resolve(time()); },
static function (): PromiseInterface { return resolve(microtime(true)); },
]));
assertType('React\Promise\PromiseInterface<array<bool|float|int>>', parallel([
static function (): bool { return true; },
static function (): int { return time(); },
static function (): float { return microtime(true); },
]));
assertType('array<bool|float|int>', await(parallel([
static function (): PromiseInterface { return resolve(true); },
static function (): PromiseInterface { return resolve(time()); },
static function (): PromiseInterface { return resolve(microtime(true)); },
])));
assertType('array<bool|float|int>', await(parallel([
static function (): bool { return true; },
static function (): int { return time(); },
static function (): float { return microtime(true); },
])));