feat: add new helper to create static closure chains

This commit is contained in:
jordanbrauer
2021-04-07 10:53:46 -05:00
parent 584a7ac8a5
commit 7d35ee9998

View File

@ -23,4 +23,14 @@ final class ChainableClosure
call_user_func_array(Closure::bind($next, $this, get_class($this)), func_get_args()); 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());
};
}
} }