cvs: pear-core(PEAR_1_3) /PEAR ErrorStack.php
| From: | Greg Beaver | Date: | Sat, 23 Oct 2004 17:17:40 +0000 |
| Subject: | cvs: pear-core(PEAR_1_3) /PEAR ErrorStack.php | ||
| Groups: | php.pear.cvs php.pear.core | ||
| Request: | Send a blank email to pear-core+get-1133@lists.php.net to get a copy of this message | ||
cellog Sat Oct 23 13:17:40 2004 EDT
Modified files: (Branch: PEAR_1_3)
/pear-core/PEAR ErrorStack.php
Log:
MFH
http://cvs.php.net/diff.php/pear-core/PEAR/ErrorStack.php?r1=1.7.2.1&r2=1.7.2.2&ty=u
Index: pear-core/PEAR/ErrorStack.php
diff -u pear-core/PEAR/ErrorStack.php:1.7.2.1 pear-core/PEAR/ErrorStack.php:1.7.2.2
--- pear-core/PEAR/ErrorStack.php:1.7.2.1 Fri Oct 22 01:40:13 2004
+++ pear-core/PEAR/ErrorStack.php Sat Oct 23 13:17:40 2004
@@ -17,7 +17,7 @@
// | |
// +----------------------------------------------------------------------+
//
-// $Id: ErrorStack.php,v 1.7.2.1 2004/10/22 05:40:13 cellog Exp $
+// $Id: ErrorStack.php,v 1.7.2.2 2004/10/23 17:17:40 cellog Exp $
/**
* Error Stack Implementation
@@ -35,8 +35,11 @@
*
* Since version 0.3alpha, it is possible to specify the exception class
* returned from {@link push()}
+ *
+ * Since version PEAR1.3.2, ErrorStack no longer instantiates an exception class. This can
+ * still be done quite handily in an error callback or by manipulating the returned array
* @author Greg Beaver <cellog@php.net>
- * @version 0.6alpha
+ * @version PEAR1.3.2 (beta)
* @package PEAR_ErrorStack
* @category Debugging
* @license http://www.php.net/license/3_0.txt PHP
License v3.0
@@ -221,13 +224,6 @@
var $_logger = false;
/**
- * Class name to use for a PHP 5 exception that will be returned
- * @var string
- * @access protected
- */
- var $_exceptionClass = 'Exception';
-
- /**
* Error messages - designed to be overridden
* @var array
* @abstract
@@ -242,20 +238,14 @@
* @param callback $contextCallback callback used for context generation,
* defaults to {@link getFileLine()}
* @param boolean $throwPEAR_Error
- * @param string $exceptionClass exception class to instantiate if
- * in PHP 5
*/
function PEAR_ErrorStack($package, $msgCallback = false, $contextCallback = false,
- $throwPEAR_Error = false, $exceptionClass = null)
+ $throwPEAR_Error = false)
{
$this->_package = $package;
$this->setMessageCallback($msgCallback);
$this->setContextCallback($contextCallback);
$this->_compat = $throwPEAR_Error;
- // this allows child classes to simply redefine $this->_exceptionClass
- if (!is_null($exceptionClass)) {
- $this->_exceptionClass = $exceptionClass;
- }
}
/**
@@ -268,15 +258,12 @@
* @param callback $contextCallback callback used for context generation,
* defaults to {@link getFileLine()}
* @param boolean $throwPEAR_Error
- * @param string $exceptionClass exception class to instantiate if
- * in PHP 5
* @param string $stackClass class to instantiate
* @static
* @return PEAR_ErrorStack
*/
function &singleton($package, $msgCallback = false, $contextCallback = false,
- $throwPEAR_Error = false, $exceptionClass = null,
- $stackClass = 'PEAR_ErrorStack')
+ $throwPEAR_Error = false, $stackClass = 'PEAR_ErrorStack')
{
if (isset($GLOBALS['_PEAR_ERRORSTACK_SINGLETON'][$package])) {
return $GLOBALS['_PEAR_ERRORSTACK_SINGLETON'][$package];
@@ -291,8 +278,7 @@
false, $trace);
}
return $GLOBALS['_PEAR_ERRORSTACK_SINGLETON'][$package] =
- &new $stackClass($package, $msgCallback, $contextCallback, $throwPEAR_Error,
- $exceptionClass);
+ &new $stackClass($package, $msgCallback, $contextCallback, $throwPEAR_Error);
}
/**
@@ -385,12 +371,16 @@
/**
* Set an error code => error message mapping callback
*
- * This method sets the callback that can be used to generate error
- * messages for any PEAR_ErrorStack instance
- * @param array|string Callback function/method
+ * This method sets the callback that can be used to generate context
+ * information for an error. Passing in NULL will disable context generation
+ * and remove the expensive call to debug_backtrace()
+ * @param array|string|null Callback function/method
*/
function setContextCallback($contextCallback)
{
+ if ($contextCallback === null) {
+ return $this->_contextCallback = false;
+ }
if (!$contextCallback) {
$this->_contextCallback = array(&$this, 'getFileLine');
} else {
@@ -506,7 +496,7 @@
* 'time' => time(),
* 'context' => $context,
* 'message' => $msg,
- * //['repackage' => $err] repackaged error array
+ * //['repackage' => $err] repackaged error array/Exception class
* );
* </code>
*/
@@ -540,8 +530,7 @@
$msg = call_user_func_array($this->_msgCallback,
array(&$this, $err));
$err['message'] = $msg;
- }
-
+ }
if ($repackage) {
$err['repackage'] = $repackage;
@@ -590,15 +579,6 @@
if ($this->_compat && $push) {
return $this->raiseError($msg, $code, null, null, $err);
}
- if (class_exists($this->_exceptionClass)) {
- $exception = $this->_exceptionClass;
- if (is_string($msg) && is_numeric($code)) {
- $code = $code + 0;
- }
- $ret = new $exception($msg, $code);
- $ret->errorData = $err;
- return $ret;
- }
return $err;
}
@@ -761,7 +741,7 @@
/**
* Get a list of all errors since last purge, organized by package
* @since PEAR 1.4.0dev BC break! $level is now in the place $merge used to be
- * @param boolean $clearStack Set to purge the error stack of existing errors
+ * @param boolean $purge Set to purge the error stack of existing errors
* @param string $level Set to a level name in order to retrieve only errors of a particular
level
* @param boolean $merge Set to return a flat array, not organized by package
* @param array $sortfunc Function used to sort a merged array - default