Not directly. $foo->anonFunction(); does not work because PHP will try to directly call the method on this object. It will not check if a property of the name that stores the called exists. You can intercept the method call though.
Add this to the class definition
public function __call($method, $args) { if(isset($this->$method) && is_callable($this->$method)) { return call_user_func_array( $this->$method, $args ); } }
This method is also explained in
source share