PEAR
[ class tree: PEAR ] [ index: PEAR ] [ all elements ]

Class: PEAR

Source Location: /main/inc/lib/pear/PEAR.php

Class Overview


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


Author(s):

Version:

  • Release: 1.4.11

Copyright:

  • 1997-2006 The PHP Group

Variables

Methods


Child classes:

OLE
OLE package base class.
OLE_PPS
Class for creating PPS's for OLE containers
OLE_ChainedBlockStream
Stream wrapper for reading data stored in an OLE file. Implements methods for PHP's stream_wrapper_register(). For creating streams using this wrapper, use OLE_PPS_File::getStream().
Spreadsheet_Excel_Writer_BIFFwriter
Class for writing Excel BIFF records.
Spreadsheet_Excel_Writer_Format
Class for generating Excel XF records (formats)
Spreadsheet_Excel_Writer_Parser
Class for parsing Excel formulas

Class Details

[line 102]
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;




Tags:

author:  Stig Bakken <ssb@php.net>
author:  Greg Beaver <cellog@php.net>
author:  Tomas V.V. Cox <cox@idecnet.com>
version:  Release: 1.4.11
copyright:  1997-2006 The PHP Group
see:  PEAR_Error
link:  http://pear.php.net/manual/en/core.pear.php#core.pear.pear
link:  http://pear.php.net/package/PEAR
since:  Class available since PHP 4.0.2
license:  PHP License 3.0


[ Top ]


Class Variables

$_debug =  false

[line 112]

Whether to enable internal debug messages.



Tags:

access:  private

Type:   bool


[ Top ]

$_default_error_handler =  ''

[line 138]

Default error handler (callback) for this object, if error mode is PEAR_ERROR_CALLBACK.



Tags:

access:  private

Type:   string


[ Top ]

$_default_error_mode =  null

[line 120]

Default error mode for this object.



Tags:

access:  private

Type:   int


[ Top ]

$_default_error_options =  null

[line 129]

Default error options used for this object when error mode is PEAR_ERROR_TRIGGER.



Tags:

access:  private

Type:   int


[ Top ]

$_error_class =  'PEAR_Error'

[line 146]

Which class to use for error objects.



Tags:

access:  private

Type:   string


[ Top ]

$_expected_errors = array()

[line 154]

An array of expected errors.



Tags:

access:  private

Type:   array


[ Top ]



Class Methods


constructor PEAR [line 170]

void PEAR( [string $error_class = null])

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



Tags:

access:  public


Parameters:

string   $error_class   (optional) which class to use for error objects, defaults to PEAR_Error.

[ Top ]

method delExpect [line 449]

mixed delExpect( mixed $error_code)

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



Tags:

return:  list of error codes that were deleted or error
since:  PHP 4.3.0
access:  public


Parameters:

mixed   $error_code   error code that should be deleted

[ Top ]

method expectError [line 384]

int expectError( [mixed $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




Tags:

return:  the new depth of the "expected errors" stack
access:  public


Parameters:

mixed   $code   a single error code or an array of error codes to expect

[ Top ]

method getStaticProperty [line 230]

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




Tags:

return:  A reference to the variable. If not set it will be auto initialised to NULL.
access:  public


Parameters:

string   $class   The calling classname, to prevent clashes
string   $var   The variable to retrieve.

[ Top ]

method isError [line 273]

bool isError( mixed $data, [int $code = null])

Tell whether a value is a PEAR error.



Tags:

return:  true if parameter is an error
access:  public


Parameters:

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

[ Top ]

method loadExtension [line 735]

bool loadExtension( string $ext)

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



Tags:

return:  Success or not on the dl() call


Parameters:

string   $ext   The extension name

[ Top ]

method popErrorHandling [line 711]

bool popErrorHandling( )

Pop the last error handler used



Tags:

return:  Always true
see:  PEAR::pushErrorHandling


[ Top ]

method popExpect [line 403]

array popExpect( )

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



Tags:

return:  the list of error codes that were popped


[ Top ]

method pushErrorHandling [line 680]

bool pushErrorHandling( mixed $mode, [mixed $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.



Tags:

return:  Always true
see:  PEAR::setErrorHandling


Parameters:

mixed   $mode   (same as setErrorHandling)
mixed   $options   (same as setErrorHandling)

[ Top ]

method raiseError [line 518]

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])

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.



Tags:

return:  PEAR error object
see:  PEAR::setErrorHandling
since:  PHP 4.0.5
access:  public


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

[ Top ]

method registerShutdownFunc [line 248]

void registerShutdownFunc( mixed $func, [mixed $args = array()])

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



Tags:

access:  public


Parameters:

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

[ Top ]

method setErrorHandling [line 329]

void setErrorHandling( [int $mode = null], [mixed $options = null])

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.




Tags:

see:  PEAR_ERROR_CALLBACK
see:  PEAR_ERROR_EXCEPTION
see:  PEAR_ERROR_DIE
see:  PEAR_ERROR_TRIGGER
see:  PEAR_ERROR_RETURN
see:  PEAR_ERROR_PRINT
since:  PHP 4.0.5
access:  public


Parameters:

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.


[ Top ]

method staticPopErrorHandling [line 630]

void staticPopErrorHandling( )



[ Top ]

method staticPushErrorHandling [line 595]

void staticPushErrorHandling( $mode, [ $options = null])



Parameters:

   $mode  
   $options  

[ Top ]

method throwError [line 581]

void &throwError( [string $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  
   $code  
   $userinfo  

[ Top ]

method _checkDelExpect [line 419]

bool _checkDelExpect( mixed $error_code)

This method checks unsets an error code if available



Tags:

return:  true if the error code was unset, false otherwise
since:  PHP 4.3.0
access:  private


Parameters:

mixed   $error_code   error code

[ Top ]

method _PEAR [line 209]

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




Tags:

access:  public


[ Top ]


Documentation generated on Thu, 12 Jun 2008 14:11:59 -0500 by phpDocumentor 1.4.1