Class PEAR

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: $obj =& new PEAR_child;

Located in /web/lib/external/pear-db/PEAR.php (line 87)


	
			
Direct descendents
Class Description
 class Spreadsheet_Excel_Writer_BIFFwriter Class for writing Excel BIFF records.
 class Spreadsheet_Excel_Writer_Parser Class for parsing Excel formulas
 class Spreadsheet_Excel_Writer_Format Class for generating Excel XF records (formats)
 class DB_storage Provides an object interface to a table row
 class DB_common DB_common is the base class from which each database driver class extends
Method Summary
 void PEAR ([string $error_class = null])
 mixed delExpect (mixed $error_code)
 int expectError ([mixed $code = '*'])
 mixed &getStaticProperty (string $class, string $var)
 bool isError (mixed $data, [int $code = null])
 bool loadExtension (string $ext)
 array popExpect ()
 bool pushErrorHandling (mixed $mode, [mixed $options = null])
 object a &raiseError ([mixed $message = null], [int $code = null], [int $mode = null], [mixed $options = null], [string $userinfo = null], [string $error_class = null], [bool $skipmsg = false])
 void registerShutdownFunc (mixed $func, [mixed $args = array()])
 void setErrorHandling ([int $mode = null], [mixed $options = null])
 void staticPushErrorHandling ( $mode, [ $options = null])
 void &throwError ([string $message = null], [ $code = null], [ $userinfo = null])
 void _PEAR ()
Methods
Constructor PEAR (line 155)

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

  • access: public
void PEAR ([string $error_class = null])
  • string $error_class: (optional) which class to use for error objects, defaults to PEAR_Error.
delExpect (line 443)

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

  • return: list of error codes that were deleted or error
  • since: PHP 4.3.0
  • access: public
mixed delExpect (mixed $error_code)
  • mixed $error_code: error code that should be deleted
expectError (line 378)

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

  • return: the new depth of the "expected errors" stack
  • access: public
int expectError ([mixed $code = '*'])
  • mixed $code: a single error code or an array of error codes to expect
getStaticProperty (line 215)

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('myclass', 'myVar'); You MUST use a reference, or they will not persist!

  • return: A reference to the variable. If not set it will be auto initialised to NULL.
  • access: public
mixed &getStaticProperty (string $class, string $var)
  • string $class: The calling classname, to prevent clashes
  • string $var: The variable to retrieve.
isError (line 266)

Tell whether a value is a PEAR error.

  • return: true if parameter is an error
  • access: public
bool isError (mixed $data, [int $code = null])
  • mixed $data: the value to test
  • int $code: if $data is an error object, return true only if $code is a string and $obj->getMessage() == $code or $code is an integer and $obj->getCode() == $code
loadExtension (line 736)

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

  • return: Success or not on the dl() call
bool loadExtension (string $ext)
  • string $ext: The extension name
popErrorHandling (line 712)

Pop the last error handler used

  • return: Always true
  • see: PEAR::pushErrorHandling
bool popErrorHandling ()
popExpect (line 397)

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

  • return: the list of error codes that were popped
array popExpect ()
pushErrorHandling (line 681)

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.

  • return: Always true
  • see: PEAR::setErrorHandling
bool pushErrorHandling (mixed $mode, [mixed $options = null])
  • mixed $mode: (same as setErrorHandling)
  • mixed $options: (same as setErrorHandling)
raiseError (line 511)

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.

  • return: PEAR error object
  • see: PEAR::setErrorHandling
  • since: PHP 4.0.5
  • access: public
object a &raiseError ([mixed $message = null], [int $code = null], [int $mode = null], [mixed $options = null], [string $userinfo = null], [string $error_class = null], [bool $skipmsg = false])
  • 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, PEAR_ERROR_CALLBACK, PEAR_ERROR_EXCEPTION.
  • 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.

Redefined in descendants as:
registerShutdownFunc (line 241)

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

  • access: public
void registerShutdownFunc (mixed $func, [mixed $args = array()])
  • mixed $func: The function name (or array of class/method) to call
  • mixed $args: The arguments to pass to the function
setErrorHandling (line 323)

Sets how errors generated by this 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.

void setErrorHandling ([int $mode = null], [mixed $options = null])
  • int $mode: One of PEAR_ERROR_RETURN, PEAR_ERROR_PRINT, PEAR_ERROR_TRIGGER, PEAR_ERROR_DIE, PEAR_ERROR_CALLBACK or PEAR_ERROR_EXCEPTION.
  • 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.

staticPopErrorHandling (line 631)
void staticPopErrorHandling ()
staticPushErrorHandling (line 596)
void staticPushErrorHandling ( $mode, [ $options = null])
  • $mode
  • $options
throwError (line 582)

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

void &throwError ([string $message = null], [ $code = null], [ $userinfo = null])
  • string $message
  • $code
  • $userinfo
_PEAR (line 194)

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.

  • access: public
void _PEAR ()

Documentation generated on Wed, 09 Feb 2011 09:03:10 +0700 by phpDocumentor 1.4.2