6 * This is a virtual class.
8 * Subclases of WikiCallback can be used to represent either
9 * global function callbacks, or object method callbacks.
11 * @see WikiFunctionCb, WikiMethodCb.
13 abstract class WikiCallback
18 * @param ? mixed This method takes a variable number of arguments (zero or more).
19 * The callback function is called with the specified arguments.
20 * @return mixed The return value of the callback.
22 public function call()
24 return $this->call_array(func_get_args());
28 * Call callback (with args in array).
30 * @param $args array Contains the arguments to be passed to the callback.
31 * @return mixed The return value of the callback.
32 * @see call_user_func_array.
34 abstract public function call_array($args);
37 * Convert to Pear callback.
39 * @return string The name of the callback function.
40 * (This value is suitable for passing as the callback parameter
41 * to a number of different Pear functions and methods.)
43 abstract public function toPearCb();
47 * Global function callback.
53 * @param string $functionName Name of global function to call.
55 public function __construct($functionName)
57 $this->functionName = $functionName;
60 function call_array($args)
62 return call_user_func_array($this->functionName, $args);
67 return $this->functionName;
72 * Object Method Callback.
78 * @param object $object Object on which to invoke method.
79 * @param string $methodName Name of method to call.
81 function __construct(&$object, $methodName)
83 $this->object = &$object;
84 $this->methodName = $methodName;
87 function call_array($args)
89 $method = &$this->methodName;
90 return call_user_func_array(array(&$this->object, $method), $args);
95 return array($this->object, $this->methodName);
100 * Anonymous function callback.
102 class WikiAnonymousCb
106 * @param string $args Argument declarations
107 * @param string $code Function body
108 * @see create_function().
110 function __construct($args, $code)
112 $this->function = create_function($args, $code);
115 function call_array($args)
117 return call_user_func_array($this->function, $args);
122 trigger_error("Can't convert WikiAnonymousCb to Pear callback",
131 // c-hanging-comment-ender-p: nil
132 // indent-tabs-mode: nil