rendered paste body<?phpclass A() { private $methods = array(); private function defaultMethods() { $this->methods['func1'] = function() { return "Foo"; }; } public function __construct() { $this->defaultMethods(); } public function __construct(array $funcs) { $this->defaultMethods(); foreach($funcs as $key => $val) { $this->methods[$key] = $val; } } public function __call($name, $arguments) { call_user_func_array($this->methods[$name], $arguments); }}$a = new A();echo $a->func1();$b = new A(array('func1' => function(){ return "Bar";}));echo $b->func1();?>