From 7d35ee99981a8507f835ff7d1b182273bc4fef0c Mon Sep 17 00:00:00 2001 From: jordanbrauer <18744334+jordanbrauer@users.noreply.github.com> Date: Wed, 7 Apr 2021 10:53:46 -0500 Subject: [PATCH] feat: add new helper to create static closure chains --- src/Support/ChainableClosure.php | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/Support/ChainableClosure.php b/src/Support/ChainableClosure.php index fea5533b..a791d0ba 100644 --- a/src/Support/ChainableClosure.php +++ b/src/Support/ChainableClosure.php @@ -23,4 +23,14 @@ final class ChainableClosure call_user_func_array(Closure::bind($next, $this, get_class($this)), func_get_args()); }; } + + public static function fromStatic(Closure $closure, Closure $next): Closure + { + return static function () use ($closure, $next): void { + /* @phpstan-ignore-next-line */ + call_user_func_array(Closure::bind($closure, null, self::class), func_get_args()); + /* @phpstan-ignore-next-line */ + call_user_func_array(Closure::bind($next, null, self::class), func_get_args()); + }; + } }