GeneralFunctions\pipeR()

higher-order variadic returns value pure
(T, ...(T → T)) → T
At a glance — Same shape as pipe but right-to-left — matches mathematical function-composition reading order.

Like pipe() but threads the value through callables right-to-left — the last callable is applied first.

/**
  * @param mixed $value
  * @param callable(mixed):mixed ...$callables
  * @return mixed
  */
GeneralFunctions\pipeR($value, callable ...$callables)

Examples

Partial Application

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

// Equivalent to strtoupper(trim('  foo  '))
echo GeneralFunctions\pipeR('  foo  ', 'strtoupper', 'trim'); // 'FOO'

Details

General Functions

Releated Composition Functions