| 1 | <?php |
||
| 6 | |||
| 7 | class TrampolineThunk |
||
| 8 | { |
||
| 9 | private \Closure $fn; |
||
|
|
|||
| 10 | |||
| 11 | public function __construct(callable $fn) |
||
| 12 | { |
||
| 13 | $this->fn = \Closure::fromCallable($fn) |
||
| 14 | ->bindTo($this); |
||
| 15 | } |
||
| 16 | |||
| 17 | /** |
||
| 18 | * @param array<int, mixed> ...$args |
||
| 19 | * @retun \Closure |
||
| 20 | */ |
||
| 21 | public function __invoke(...$args): \Closure |
||
| 22 | { |
||
| 23 | $fn = $this->fn; |
||
| 24 | |||
| 25 | return function () use ($args, $fn) { |
||
| 26 | return $fn(...$args); |
||
| 27 | }; |
||
| 28 | } |
||
| 30 |