Last active
August 29, 2015 14:13
-
-
Save beerendlauwers/c28585ce4868ab42d2f9 to your computer and use it in GitHub Desktop.
Revisions
-
beerendlauwers revised this gist
Jan 9, 2015 . 1 changed file with 3 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -27,4 +27,6 @@ class Test { $t = new Test(); $t->addFunction( function($x){ return $x; } ); $t->addFunction( function($x){ return $x; } ); $t->apply(TRUE); ?> -
beerendlauwers created this gist
Jan 9, 2015 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,30 @@ <?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("test");