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 1010interface PoolInterface extends PoolInfoInterface
1111{
1212 /**
13- * @param (Closure():T) $callable
14- * @param array<mixed > $args
13+ * @param (Closure(A ...$args ):T) $callable
14+ * @param array<A > $args
1515 *
1616 * @return T
1717 *
1818 * @template T
19+ * @template A
1920 */
2021 public function run (Closure $ callable , array $ args = []): mixed ;
2122
Original file line number Diff line number Diff line change 55namespace ReactParallel \Tests \Contracts ;
66
77use Closure ;
8+ use ReactParallel \Contracts \PoolInterface ;
89use WyriHaximus \PoolInfo \PoolInfoInterface ;
910
11+ /**
12+ * @phpstan-implements PoolInterface
13+ */
1014final class MockPool implements PoolInfoInterface
1115{
1216 /** @return iterable<string, int> */
@@ -15,14 +19,6 @@ public function info(): iterable
1519 yield from [];
1620 }
1721
18- /**
19- * @param (Closure():T) $callable
20- * @param array<mixed> $args
21- *
22- * @return T
23- *
24- * @template T
25- */
2622 public function run (Closure $ callable , array $ args = []): mixed
2723 {
2824 return $ callable (...$ args );
Original file line number Diff line number Diff line change 22
33declare (strict_types=1 );
44
5+ use ReactParallel \Contracts \PoolInterface ;
56use ReactParallel \Tests \Contracts \MockPool ;
67
78use function PHPStan \Testing \assertType ;
89
10+ /** @var PoolInterface $pool */
911$ pool = new MockPool ();
1012
1113assertType ('bool ' , $ pool ->run (static function (): bool {
1517assertType ('bool|int ' , $ pool ->run (static function (): bool |int {
1618 return time () % 2 !== 0 ? true : time ();
1719}));
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