update to PHP-8.1
[m6w6/seekat] / lib / API / Future / functions.php
1 <?php
2
3 namespace seekat\API\Future;
4
5 use seekat\API\Future;
6
7 function react() : React2 {
8 return new React2;
9 }
10
11 function amp() : Amp2 {
12 return new Amp2;
13 }
14
15 function any() : Amp2|React2 {
16 if (interface_exists(\Amp\Promise::class, true)) {
17 return amp();
18 }
19 if (interface_exists(\React\Promise\PromiseInterface::class, true)) {
20 return react();
21 }
22 throw new \Exception("Cannot find any promise implementation");
23 }