Class Callback

Description

Common interface to different types of callable functions and methods

Examples:

  1.  /* creating a callback from a procedural function */
  2.  $func new Callback('strtoupper');
  3.  $upper $func->invoke('hello world');
  4.  
  5.  /* creating a callback from a static method */
  6.  $method new Callback('MyClass::myMethod');
  7.  /* invoke it with 3 arguments */
  8.  $method->invoke(array($a$b$c)TRUE);
  9.  
  10.  /* creating a callback from an object's method */
  11.  $obj new MyClass();
  12.  $callback new Callback(array($obj'myMethod'));
  13.  $callback->invoke($arg);

Located in /core/util/Callback.class.php (line 68)

PHP2Go
   |
   --Callback
Variable Summary
mixed $function
int $type
bool $valid
Method Summary
Callback Callback ([string|array $function = NULL])
int getType ()
mixed invoke ([mixed $args = NULL], [bool $nargs = FALSE])
mixed invokeByRef (mixed &$argument)
bool isType (int $type)
bool isValid ()
void setFunction (string|array $function)
void setFunctionByRef ( &$function, mixed $function)
void setThrowErrors (bool $setting)
void _parseFunction ()
string __toString ()
Variables
mixed $function = NULL (line 75)

Current callback

bool $throwErrors = TRUE (line 96)

Throw an error when an invalid callback is detected

int $type (line 82)

Current callback type

bool $valid = FALSE (line 89)

Indicates if the current callback is valid

Methods
static method getInstance (line 118)

Get the singleton of the Callback class

static Callback &getInstance ()
Constructor Callback (line 104)

Class constructor

Callback Callback ([string|array $function = NULL])
  • string|array $function: Callback specification
getType (line 130)

Get the type of the current callback

int getType ()
invoke (line 196)

Invoke the callback with the given arguments

The $args parameter will be used as argument of the function or method. To invoke the callback with N arguments, $args must be an array and $nargs must be TRUE.

  • return: Callback return
mixed invoke ([mixed $args = NULL], [bool $nargs = FALSE])
  • mixed $args: Callback arguments
  • bool $nargs: Multiple arguments flag
invokeByRef (line 208)

Invoke the callback with a single parameter by reference

  • return: Callback return
mixed invokeByRef (mixed &$argument)
  • mixed &$argument: Callback argument
isType (line 140)

Checks if the current callback is of a given type

bool isType (int $type)
  • int $type: Type
isValid (line 149)

Checks if the current callback is valid

bool isValid ()
setFunction (line 158)

Changes or defines the callback

void setFunction (string|array $function)
  • string|array $function: Callback
setFunctionByRef (line 170)

Defines the callback by reference

This is useful when defining object methods as callbacks under PHP4.

void setFunctionByRef ( &$function, mixed $function)
  • mixed $function: Callback
  • &$function
setThrowErrors (line 180)

Enable/disable errors when invalid callbacks are detected

void setThrowErrors (bool $setting)
  • bool $setting: Boolean value
_parseFunction (line 233)

Defines type and validity of the current callback

  • access: private
void _parseFunction ()
__toString (line 222)

Builds a string representation of the object

string __toString ()

Redefinition of:
PHP2Go::__toString()
Generate a string representation of the object

Inherited Methods

Inherited From PHP2Go

PHP2Go::PHP2Go()
PHP2Go::equals()
PHP2Go::generateUniqueId()
PHP2Go::getClassName()
PHP2Go::getConfigVal()
PHP2Go::getLangVal()
PHP2Go::getObjectName()
PHP2Go::getParentName()
PHP2Go::hasDestructor()
PHP2Go::hashCode()
PHP2Go::isA()
PHP2Go::isSubclassOf()
PHP2Go::logError()
PHP2Go::raiseError()
PHP2Go::registerDestructor()
PHP2Go::registerShutdownFunc()
PHP2Go::retrieve()
PHP2Go::store()
PHP2Go::__toString()

Documentation generated on Sun, 07 Oct 2007 19:20:44 -0300 by phpDocumentor 1.3.2