File tree Expand file tree Collapse file tree 3 files changed +17
-10
lines changed Expand file tree Collapse file tree 3 files changed +17
-10
lines changed Original file line number Diff line number Diff line change 10
10
interface PoolInterface extends PoolInfoInterface
11
11
{
12
12
/**
13
- * @param (Closure():T) $callable
14
- * @param array<mixed > $args
13
+ * @param (Closure(A ...$args ):T) $callable
14
+ * @param array<A > $args
15
15
*
16
16
* @return T
17
17
*
18
18
* @template T
19
+ * @template A
19
20
*/
20
21
public function run (Closure $ callable , array $ args = []): mixed ;
21
22
Original file line number Diff line number Diff line change 5
5
namespace ReactParallel \Tests \Contracts ;
6
6
7
7
use Closure ;
8
+ use ReactParallel \Contracts \PoolInterface ;
8
9
use WyriHaximus \PoolInfo \PoolInfoInterface ;
9
10
11
+ /**
12
+ * @phpstan-implements PoolInterface
13
+ */
10
14
final class MockPool implements PoolInfoInterface
11
15
{
12
16
/** @return iterable<string, int> */
@@ -15,14 +19,6 @@ public function info(): iterable
15
19
yield from [];
16
20
}
17
21
18
- /**
19
- * @param (Closure():T) $callable
20
- * @param array<mixed> $args
21
- *
22
- * @return T
23
- *
24
- * @template T
25
- */
26
22
public function run (Closure $ callable , array $ args = []): mixed
27
23
{
28
24
return $ callable (...$ args );
Original file line number Diff line number Diff line change 2
2
3
3
declare (strict_types=1 );
4
4
5
+ use ReactParallel \Contracts \PoolInterface ;
5
6
use ReactParallel \Tests \Contracts \MockPool ;
6
7
7
8
use function PHPStan \Testing \assertType ;
8
9
10
+ /** @var PoolInterface $pool */
9
11
$ pool = new MockPool ();
10
12
11
13
assertType ('bool ' , $ pool ->run (static function (): bool {
15
17
assertType ('bool|int ' , $ pool ->run (static function (): bool |int {
16
18
return time () % 2 !== 0 ? true : time ();
17
19
}));
20
+
21
+ assertType ('bool|int ' , $ pool ->run (static function (int $ mod ): bool |int {
22
+ return time () % $ mod !== 0 ? true : time ();
23
+ }, [2 ]));
24
+
25
+ assertType ('bool|int ' , $ pool ->run (static function (int $ mod , bool $ yolo ): bool |int {
26
+ return time () % $ mod !== 0 ? $ yolo : time ();
27
+ }, [2 , true ]));
You can’t perform that action at this time.
0 commit comments