GeneralFunctions\invoker()

higher-order returns Closure pure
((A) → R) → ((...A) → R)
At a glance — Wraps a callable so it can be called uniformly. Mostly useful for adapting PHP's callable-ness into a consistent Closure shape.

Creates a Closure that invokes a bound callable with whatever arguments you pass to the Closure. Useful as a value-level representation of calling something.

/**
  * @param callable(mixed):mixed $fn
  * @return Closure(mixed ...):mixed
  */
GeneralFunctions\invoker(callable $fn): Closure

Examples

Partial Application

This can be used to create a simple closure which can be used as a regular function.

$trim = GeneralFunctions\invoker('trim');

echo $trim('  foo  '); // 'foo'

Details

General Functions

Releated Combinators Functions