eZPublish  3.8
PEAR Class Reference

Base class for other PEAR classes. More...

Public Member Functions

 _PEAR ()
 Destructor (the emulated type of...). More...
 
 expectError ($code="*")
 This method is used to tell which errors you expect to get. More...
 
 isError ($data)
 Tell whether a value is a PEAR error. More...
 
 PEAR ($error_class=null)
 Constructor. More...
 
 popErrorHandling ()
 Pop the last error handler used. More...
 
 popExpect ()
 This method pops one element off the expected error codes stack. More...
 
 pushErrorHandling ($mode, $options=null)
 Push a new error handler on top of the error handler options stack. More...
 
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. More...
 
 setErrorHandling ($mode=null, $options=null)
 Sets how errors generated by this DB object should be handled. More...
 

Public Attributes

 $_debug = false
 
 $_default_error_handler = ''
 
 $_default_error_mode = null
 
 $_default_error_options = null
 
 $_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 "</em>" 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.

Since
PHP 4.0.2
Author
Stig Bakken ssb@f.nosp@m.ast..nosp@m.no

Member Function Documentation

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
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.

Parameters
mixeda single error code or an array of error codes to expect
Returns
int the new depth of the "expected errors" stack
PEAR::isError (   $data)

Tell whether a value is a PEAR error.

Parameters
mixedthe value to test public
Returns
bool true if parameter is an error
PEAR::PEAR (   $error_class = null)

Constructor.

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

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

Pop the last error handler used.

Returns
bool Always true
See Also
PEAR::pushErrorHandling
PEAR::popExpect ( )

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

Returns
array the list of error codes that were popped
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
$modemixed (same as setErrorHandling)
$optionsmixed (same as setErrorHandling)
Returns
bool Always true
See Also
PEAR::setErrorHandling
& 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
$messagea text error message or a PEAR error object
$codea numeric error code (it is up to your class to define these if you want to use codes)
$modeOne of PEAR_ERROR_RETURN, PEAR_ERROR_PRINT, PEAR_ERROR_TRIGGER, PEAR_ERROR_DIE or PEAR_ERROR_CALLBACK.
$optionsIf $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.
$userinfoIf you need to pass along for example debug information, this parameter is meant for that.
$error_classThe returned error object will be instantiated from this class, if specified.
$skipmsgIf 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
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$modeOne of PEAR_ERROR_RETURN, PEAR_ERROR_PRINT, PEAR_ERROR_TRIGGER, PEAR_ERROR_DIE or PEAR_ERROR_CALLBACK.
mixed$optionsWhen $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

Referenced by popErrorHandling(), and pushErrorHandling().

Member Data Documentation

PEAR::$_debug = false
PEAR::$_default_error_handler = ''
PEAR::$_default_error_mode = null
PEAR::$_default_error_options = null
PEAR::$_error_class = 'PEAR_Error'

Referenced by raiseError().

PEAR::$_expected_errors = array()

Referenced by expectError().


The documentation for this class was generated from the following file: