Main Page | Namespace List | Class Hierarchy | Class List | File List | Class Members | File Members | Related Pages

PEAR Class Reference

List of all members.

Public Member Functions

 PEAR ($error_class=null)
 _PEAR ()
getStaticProperty ($class, $var)
 registerShutdownFunc ($func, $args=array())
 isError ($data)
 setErrorHandling ($mode=null, $options=null)
 expectError ($code= '*')
 popExpect ()
 _checkDelExpect ($error_code)
 delExpect ($error_code)
raiseError ($message=null, $code=null, $mode=null, $options=null, $userinfo=null, $error_class=null, $skipmsg=false)
throwError ($message=null, $code=null, $userinfo=null)
 pushErrorHandling ($mode, $options=null)
 popErrorHandling ()
 loadExtension ($ext)

Public Attributes

 $_debug = false
 $_default_error_mode = null
 $_default_error_options = null
 $_default_error_handler = ''
 $_error_class = 'PEAR_Error'
 $_expected_errors = array()

Detailed Description

Base class for other PEAR classes. Provides rudimentary emulation of destructors.

If you want a destructor in your class, inherit PEAR and make a destructor method called _yourclassname (same name as the constructor, but with a "_" prefix). Also, in your constructor you have to call the PEAR constructor: $this->PEAR();. The destructor method will be called without parameters. Note that at in some SAPI implementations (such as Apache), any output during the request shutdown (in which destructors are called) seems to be discarded. If you need to get any debug information from your destructor, use error_log(), syslog() or something similar.

IMPORTANT! To use the emulated destructors you need to create the objects by reference, ej: $obj =& new PEAR_child;

Since:
PHP 4.0.2
Author:
Stig Bakken <ssb@fast.no>
See also:
http://pear.php.net/manual/

Definition at line 71 of file PEAR.php.


Constructor & Destructor Documentation

PEAR::PEAR error_class = null  ) 
 

Constructor. Registers this object in $_PEAR_destructor_object_list for destructor emulation if a destructor object exists.

Parameters:
string $error_class (optional) which class to use for error objects, defaults to PEAR_Error. public
Returns:
void

Definition at line 139 of file PEAR.php.


Member Function Documentation

PEAR::_checkDelExpect error_code  ) 
 

This method checks unsets an error code if available

Parameters:
mixed error code
Returns:
bool true if the error code was unset, false otherwise private
Since:
PHP 4.3.0

Definition at line 365 of file PEAR.php.

References _checkDelExpect().

Referenced by _checkDelExpect().

PEAR::_PEAR  ) 
 

Destructor (the emulated type of...). Does nothing right now, but is included for forward compatibility, so subclass destructors should always call it.

See the note in the class desciption about output from destructors.

public

Returns:
void

Definition at line 174 of file PEAR.php.

PEAR::delExpect error_code  ) 
 

This method deletes all occurences of the specified element from the expected error codes stack.

Parameters:
mixed $error_code error code that should be deleted
Returns:
mixed list of error codes that were deleted or error public
Since:
PHP 4.3.0

Definition at line 395 of file PEAR.php.

References delExpect(), and raiseError().

Referenced by delExpect().

PEAR::expectError code = '*'  ) 
 

This method is used to tell which errors you expect to get. Expected errors are always returned with error mode PEAR_ERROR_RETURN. Expected error codes are stored in a stack, and this method pushes a new element onto it. The list of expected errors are in effect until they are popped off the stack with the popExpect() method.

Note that this method can not be called statically

Parameters:
mixed $code a single error code or an array of error codes to expect
Returns:
int the new depth of the "expected errors" stack public

Definition at line 330 of file PEAR.php.

References expectError().

Referenced by expectError().

& PEAR::getStaticProperty class,
var
 

If you have a class that's mostly/entirely static, and you need static properties, you can use this method to simulate them. Eg. in your method(s) do this: $myVar = &PEAR::getStaticProperty('myVar'); You MUST use a reference, or they will not persist!

public

Parameters:
string $class The calling classname, to prevent clashes
string $var The variable to retrieve.
Returns:
mixed A reference to the variable. If not set it will be auto initialised to NULL.

Definition at line 195 of file PEAR.php.

References getStaticProperty().

Referenced by getStaticProperty().

PEAR::isError data  ) 
 

Tell whether a value is a PEAR error.

Parameters:
mixed $data the value to test public
Returns:
bool true if parameter is an error

Definition at line 228 of file PEAR.php.

References data, and isError().

Referenced by isError().

PEAR::loadExtension ext  ) 
 

OS independant PHP extension load. Remember to take care on the correct extension name for case sensitive OSes.

Parameters:
string $ext The extension name
Returns:
bool Success or not on the dl() call

Definition at line 605 of file PEAR.php.

References loadExtension().

Referenced by loadExtension().

PEAR::popErrorHandling  ) 
 

Pop the last error handler used

Returns:
bool Always true
See also:
PEAR::pushErrorHandling

Definition at line 581 of file PEAR.php.

References $GLOBALS, and setErrorHandling().

PEAR::popExpect  ) 
 

This method pops one element off the expected error codes stack.

Returns:
array the list of error codes that were popped

Definition at line 349 of file PEAR.php.

PEAR::pushErrorHandling mode,
options = null
 

Push a new error handler on top of the error handler options stack. With this you can easily override the actual error handler for some code and restore it later with popErrorHandling.

Parameters:
mixed $mode (same as setErrorHandling)
mixed $options (same as setErrorHandling)
Returns:
bool Always true
See also:
PEAR::setErrorHandling

Definition at line 550 of file PEAR.php.

References $GLOBALS, pushErrorHandling(), and setErrorHandling().

Referenced by pushErrorHandling().

& PEAR::raiseError message = null,
code = null,
mode = null,
options = null,
userinfo = null,
error_class = null,
skipmsg = false
 

This method is a wrapper that returns an instance of the configured error class with this object's default error handling applied. If the $mode and $options parameters are not specified, the object's defaults are used.

Parameters:
mixed $message a text error message or a PEAR error object
int $code a numeric error code (it is up to your class to define these if you want to use codes)
int $mode One of PEAR_ERROR_RETURN, PEAR_ERROR_PRINT, PEAR_ERROR_TRIGGER, PEAR_ERROR_DIE or PEAR_ERROR_CALLBACK.
mixed $options If $mode is PEAR_ERROR_TRIGGER, this parameter specifies the PHP-internal error level (one of E_USER_NOTICE, E_USER_WARNING or E_USER_ERROR). If $mode is PEAR_ERROR_CALLBACK, this parameter specifies the callback function or method. In other error modes this parameter is ignored.
string $userinfo If you need to pass along for example debug information, this parameter is meant for that.
string $error_class The returned error object will be instantiated from this class, if specified.
bool $skipmsg If true, raiseError will only pass error codes, the error message parameter will be dropped.
public
Returns:
object a PEAR error object
See also:
PEAR::setErrorHandling
Since:
PHP 4.0.5

Definition at line 464 of file PEAR.php.

References $GLOBALS, $options, PEAR_ERROR_RETURN, and raiseError().

Referenced by delExpect(), raiseError(), and throwError().

PEAR::registerShutdownFunc func,
args = array()
 

Use this function to register a shutdown method for static classes.

public

Parameters:
mixed $func The function name (or array of class/method) to call
mixed $args The arguments to pass to the function
Returns:
void

Definition at line 213 of file PEAR.php.

References $GLOBALS, and registerShutdownFunc().

Referenced by registerShutdownFunc().

PEAR::setErrorHandling mode = null,
options = null
 

Sets how errors generated by this DB object should be handled. Can be invoked both in objects and statically. If called statically, setErrorHandling sets the default behaviour for all PEAR objects. If called in an object, setErrorHandling sets the default behaviour for that object.

Parameters:
int $mode One of PEAR_ERROR_RETURN, PEAR_ERROR_PRINT, PEAR_ERROR_TRIGGER, PEAR_ERROR_DIE or PEAR_ERROR_CALLBACK.
mixed $options When $mode is PEAR_ERROR_TRIGGER, this is the error level (one of E_USER_NOTICE, E_USER_WARNING or E_USER_ERROR).
When $mode is PEAR_ERROR_CALLBACK, this parameter is expected to be the callback function or method. A callback function is a string with the name of the function, a callback method is an array of two elements: the element at index 0 is the object, and the element at index 1 is the name of the method to call in the object.

When $mode is PEAR_ERROR_PRINT or PEAR_ERROR_DIE, this is a printf format string used when printing the error message.

public

Returns:
void
See also:
PEAR_ERROR_RETURN

PEAR_ERROR_PRINT

PEAR_ERROR_TRIGGER

PEAR_ERROR_DIE

PEAR_ERROR_CALLBACK

Since:
PHP 4.0.5

Definition at line 275 of file PEAR.php.

References $GLOBALS, $options, PEAR_ERROR_CALLBACK, PEAR_ERROR_DIE, PEAR_ERROR_PRINT, PEAR_ERROR_RETURN, PEAR_ERROR_TRIGGER, and setErrorHandling().

Referenced by popErrorHandling(), pushErrorHandling(), and setErrorHandling().

& PEAR::throwError message = null,
code = null,
userinfo = null
 

Simpler form of raiseError with fewer options. In most cases message, code and userinfo are enough.

Parameters:
string $message

Definition at line 524 of file PEAR.php.

References raiseError(), and throwError().

Referenced by throwError().


Member Data Documentation

PEAR::$_debug = false
 

Definition at line 81 of file PEAR.php.

PEAR::$_default_error_handler = ''
 

Definition at line 107 of file PEAR.php.

PEAR::$_default_error_mode = null
 

Definition at line 89 of file PEAR.php.

PEAR::$_default_error_options = null
 

Definition at line 98 of file PEAR.php.

PEAR::$_error_class = 'PEAR_Error'
 

Definition at line 115 of file PEAR.php.

PEAR::$_expected_errors = array()
 

Definition at line 123 of file PEAR.php.


The documentation for this class was generated from the following file:
Generated on Tue Jun 29 23:40:51 2004 for Mediawiki by doxygen 1.3.7