]> granicus.if.org Git - php/commitdiff
* only register the destructor if it exists
authorStig Bakken <ssb@php.net>
Sat, 10 Mar 2001 09:59:15 +0000 (09:59 +0000)
committerStig Bakken <ssb@php.net>
Sat, 10 Mar 2001 09:59:15 +0000 (09:59 +0000)
pear/PEAR.php.in

index 354d244d57d2d57af7a883270f7ae210d7820299..9ff0e54619e6994d82daf0260f6d8a95bcaed9d3 100644 (file)
@@ -73,11 +73,14 @@ class PEAR
 
     /**
      * Constructor.  Registers this object in
-     * $_PEAR_destructor_object_list for destructor emulation.
+     * $_PEAR_destructor_object_list for destructor emulation if a
+     * destructor object exists.
      */
     function PEAR() {
-        global $_PEAR_destructor_object_list;
-        $_PEAR_destructor_object_list[] = &$this;
+        if (method_exists($this, "_".get_class($this))) {
+            global $_PEAR_destructor_object_list;
+            $_PEAR_destructor_object_list[] = &$this;
+        }
         if ($this->_debug) {
             printf("PEAR constructor called, class=%s\n",
                    get_class($this));
@@ -199,7 +202,30 @@ class PEAR
     // {{{ raiseError()
 
     /**
-     * This method is called by DB to generate an error.
+     * This method is a wrapper that returns an instance of PEAR_Error
+     * with this object's default error handling applied.  If the
+     * $mode and $options parameters are not specified, the object's
+     * defaults are used.
+     *
+     * @param $message  a text error message
+     * @param $code     a numeric error code (it is up to your class
+     *                  to define these if you want to use codes)
+     * @param $mode     One of PEAR_ERROR_RETURN, PEAR_ERROR_PRINT,
+     *                  PEAR_ERROR_TRIGGER, PEAR_ERROR_DIE or
+     *                  PEAR_ERROR_CALLBACK.
+     * @param $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.
+     * @param $userinfo If you need to pass along for example debug
+     *                  information, this parameter is meant for that.
+     *
+     * @return object   a PEAR error object
+     *
+     * @see PEAR::setErrorHandling
      *
      * @since PHP 4.0.5
      */