Skip to content

Commit 0a1def7

Browse files
authored
Merge pull request #6 from reactphp-parallel/template-types-with-async-await-API
Template types with async/await API
2 parents a3e28c0 + bf23ce7 commit 0a1def7

File tree

5 files changed

+85
-90
lines changed

5 files changed

+85
-90
lines changed

composer.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
],
1212
"require": {
1313
"php": "^8.2",
14-
"react/promise": "^3",
1514
"wyrihaximus/pool-info": "^2"
1615
},
1716
"require-dev": {

composer.lock

Lines changed: 74 additions & 74 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/PoolInterface.php

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,20 +5,19 @@
55
namespace ReactParallel\Contracts;
66

77
use Closure;
8-
use React\Promise\PromiseInterface;
98
use WyriHaximus\PoolInfo\PoolInfoInterface;
109

1110
interface PoolInterface extends PoolInfoInterface
1211
{
1312
/**
14-
* @param (Closure():(PromiseInterface<T>|T)) $callable
15-
* @param array<mixed> $args
13+
* @param (Closure():T) $callable
14+
* @param array<mixed> $args
1615
*
17-
* @return PromiseInterface<T>
16+
* @return T
1817
*
1918
* @template T
2019
*/
21-
public function run(Closure $callable, array $args = []): PromiseInterface;
20+
public function run(Closure $callable, array $args = []): mixed;
2221

2322
/**
2423
* Gently close every thread in the pool.

tests/MockPool.php

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,8 @@
55
namespace ReactParallel\Tests\Contracts;
66

77
use Closure;
8-
use React\Promise\PromiseInterface;
98
use WyriHaximus\PoolInfo\PoolInfoInterface;
109

11-
use function React\Promise\resolve;
12-
1310
final class MockPool implements PoolInfoInterface
1411
{
1512
/** @return iterable<string, int> */
@@ -19,16 +16,16 @@ public function info(): iterable
1916
}
2017

2118
/**
22-
* @param (Closure():(PromiseInterface<T>|T)) $callable
23-
* @param array<mixed> $args
19+
* @param (Closure():T) $callable
20+
* @param array<mixed> $args
2421
*
25-
* @return PromiseInterface<T>
22+
* @return T
2623
*
2724
* @template T
2825
*/
29-
public function run(Closure $callable, array $args = []): PromiseInterface
26+
public function run(Closure $callable, array $args = []): mixed
3027
{
31-
return resolve($callable(...$args));
28+
return $callable(...$args);
3229
}
3330

3431
public function close(): bool

tests/Types.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@
88

99
$pool = new MockPool();
1010

11-
assertType('React\Promise\PromiseInterface<bool>', $pool->run(static function (): bool {
11+
assertType('bool', $pool->run(static function (): bool {
1212
return true;
1313
}));
1414

15-
assertType('React\Promise\PromiseInterface<bool|int>', $pool->run(static function (): bool|int {
15+
assertType('bool|int', $pool->run(static function (): bool|int {
1616
return time() % 2 !== 0 ? true : time();
1717
}));

0 commit comments

Comments
 (0)