Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
<?php
class Test {
private $f = NULL;
public function addFunction( callable $f ) {
if ($this->f === NULL) {
$this->f = $f;
}
else {
$this->f = function() use ($f){
$args = func_get_args();
return call_user_func_array( $this->f, $args ) &&
call_user_func_array( $f, $args );
};
}
}
public function apply() {
$args = func_get_args();
call_user_func_array( $this->f, $args );
}
}
$t = new Test();
$t->addFunction( function($x){ return $x; } );
$t->addFunction( function($x){ return $x; } );
$t->apply(TRUE);
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment