File tree Expand file tree Collapse file tree 5 files changed +85
-90
lines changed Expand file tree Collapse file tree 5 files changed +85
-90
lines changed Original file line number Diff line number Diff line change 11
11
],
12
12
"require" : {
13
13
"php" : " ^8.2" ,
14
- "react/promise" : " ^3" ,
15
14
"wyrihaximus/pool-info" : " ^2"
16
15
},
17
16
"require-dev" : {
Original file line number Diff line number Diff line change 5
5
namespace ReactParallel \Contracts ;
6
6
7
7
use Closure ;
8
- use React \Promise \PromiseInterface ;
9
8
use WyriHaximus \PoolInfo \PoolInfoInterface ;
10
9
11
10
interface PoolInterface extends PoolInfoInterface
12
11
{
13
12
/**
14
- * @param (Closure():(PromiseInterface<T>|T) ) $callable
15
- * @param array<mixed> $args
13
+ * @param (Closure():T ) $callable
14
+ * @param array<mixed> $args
16
15
*
17
- * @return PromiseInterface<T>
16
+ * @return T
18
17
*
19
18
* @template T
20
19
*/
21
- public function run (Closure $ callable , array $ args = []): PromiseInterface ;
20
+ public function run (Closure $ callable , array $ args = []): mixed ;
22
21
23
22
/**
24
23
* Gently close every thread in the pool.
Original file line number Diff line number Diff line change 5
5
namespace ReactParallel \Tests \Contracts ;
6
6
7
7
use Closure ;
8
- use React \Promise \PromiseInterface ;
9
8
use WyriHaximus \PoolInfo \PoolInfoInterface ;
10
9
11
- use function React \Promise \resolve ;
12
-
13
10
final class MockPool implements PoolInfoInterface
14
11
{
15
12
/** @return iterable<string, int> */
@@ -19,16 +16,16 @@ public function info(): iterable
19
16
}
20
17
21
18
/**
22
- * @param (Closure():(PromiseInterface<T>|T) ) $callable
23
- * @param array<mixed> $args
19
+ * @param (Closure():T ) $callable
20
+ * @param array<mixed> $args
24
21
*
25
- * @return PromiseInterface<T>
22
+ * @return T
26
23
*
27
24
* @template T
28
25
*/
29
- public function run (Closure $ callable , array $ args = []): PromiseInterface
26
+ public function run (Closure $ callable , array $ args = []): mixed
30
27
{
31
- return resolve ( $ callable (...$ args) );
28
+ return $ callable (...$ args );
32
29
}
33
30
34
31
public function close (): bool
Original file line number Diff line number Diff line change 8
8
9
9
$ pool = new MockPool ();
10
10
11
- assertType ('React\Promise\PromiseInterface< bool> ' , $ pool ->run (static function (): bool {
11
+ assertType ('bool ' , $ pool ->run (static function (): bool {
12
12
return true ;
13
13
}));
14
14
15
- assertType ('React\Promise\PromiseInterface< bool|int> ' , $ pool ->run (static function (): bool |int {
15
+ assertType ('bool|int ' , $ pool ->run (static function (): bool |int {
16
16
return time () % 2 !== 0 ? true : time ();
17
17
}));
You can’t perform that action at this time.
0 commit comments