dev-master
9999999-devFunction partial application
MIT
The Requires
- php >=5.5.0
The Development Requires
by Simone Salerno
1.0.0
1.0.0.0Function partial application
MIT
The Requires
- php >=5.5.0
The Development Requires
by Simone Salerno
Wallogit.com
2017 © Pedro Peláez
Function partial application
Apply partial arguments to your functions., (*2)
$ composer require simones/partial
Bind a subset of a function's arguments and get a new function back that accepts the remaining arguments. It is most useful if you write functional programming or don't like using use with anonymous functions.
You can get a Partial instance via instantiation or with the partial helper., (*3)
Here are some examples (for more, head to the spec):, (*4)
// one-argument binding
$hello = partial('printf', ['Hello, %s']);
$hello('world') // print "Hello, world"
// or
$hello->call('world')
// multiple arguments binding
$countdown = partial('printf', ['%s, %s, %s, go!', 'Three']);
$countdown('Two', 'One'); // print "Three, Two, One, go!"
// you can skip argument, and they will be filled on call time
$countdown = partial('printf', ['%s, %s, %s, go!', Partial::SKIP, 'Two']);
$countdown('Trhee', 'One'); // print "Three, Two, One, go!"
Function partial application
MIT
Function partial application
MIT