* @author Greg Beaver <cellog@php.net>
* @copyright 2004-2008 Greg Beaver
* @license http://opensource.org/licenses/bsd-license.php New BSD License
- * @version CVS: $Id: ErrorStack.php 313023 2011-07-06 19:17:11Z dufuz $
* @link http://pear.php.net/package/PEAR_ErrorStack
*/
* $local_stack = new PEAR_ErrorStack('MyPackage');
* </code>
* @author Greg Beaver <cellog@php.net>
- * @version 1.9.4
+ * @version 1.10.1
* @package PEAR_ErrorStack
* @category Debugging
* @copyright 2004-2008 Greg Beaver
* @license http://opensource.org/licenses/bsd-license.php New BSD License
- * @version CVS: $Id: ErrorStack.php 313023 2011-07-06 19:17:11Z dufuz $
* @link http://pear.php.net/package/PEAR_ErrorStack
*/
class PEAR_ErrorStack {
* @access protected
*/
var $_contextCallback = false;
-
+
/**
* If set to a valid callback, this will be called every time an error
* is pushed onto the stack. The return value will be used to determine
* whether to allow an error to be pushed or logged.
- *
+ *
* The return value must be one an PEAR_ERRORSTACK_* constant
* @see PEAR_ERRORSTACK_PUSHANDLOG, PEAR_ERRORSTACK_PUSH, PEAR_ERRORSTACK_LOG
* @var false|string|array
* @access protected
*/
var $_errorCallback = array();
-
+
/**
* PEAR::Log object for logging errors
* @var false|Log
* @access protected
*/
var $_logger = false;
-
+
/**
* Error messages - designed to be overridden
* @var array
* @abstract
*/
var $_errorMsgs = array();
-
+
/**
* Set up a new error stack
- *
+ *
* @param string $package name of the package this error stack represents
* @param callback $msgCallback callback used for error message generation
* @param callback $contextCallback callback used for context generation,
* defaults to {@link getFileLine()}
* @param boolean $throwPEAR_Error
*/
- function PEAR_ErrorStack($package, $msgCallback = false, $contextCallback = false,
+ function __construct($package, $msgCallback = false, $contextCallback = false,
$throwPEAR_Error = false)
{
$this->_package = $package;
* defaults to {@link getFileLine()}
* @param boolean $throwPEAR_Error
* @param string $stackClass class to instantiate
- * @static
+ *
* @return PEAR_ErrorStack
*/
- function &singleton($package, $msgCallback = false, $contextCallback = false,
- $throwPEAR_Error = false, $stackClass = 'PEAR_ErrorStack')
- {
+ public static function &singleton(
+ $package, $msgCallback = false, $contextCallback = false,
+ $throwPEAR_Error = false, $stackClass = 'PEAR_ErrorStack'
+ ) {
if (isset($GLOBALS['_PEAR_ERRORSTACK_SINGLETON'][$package])) {
return $GLOBALS['_PEAR_ERRORSTACK_SINGLETON'][$package];
}
/**
* Set up a PEAR::Log object for all error stacks that don't have one
* @param Log $log
- * @static
*/
- function setDefaultLogger(&$log)
+ public static function setDefaultLogger(&$log)
{
if (is_object($log) && method_exists($log, 'log') ) {
$GLOBALS['_PEAR_ERRORSTACK_DEFAULT_LOGGER'] = &$log;
} elseif (is_callable($log)) {
$GLOBALS['_PEAR_ERRORSTACK_DEFAULT_LOGGER'] = &$log;
- }
+ }
}
/**
* messages for a singleton
* @param array|string Callback function/method
* @param string Package name, or false for all packages
- * @static
*/
- function setDefaultCallback($callback = false, $package = false)
+ public static function setDefaultCallback($callback = false, $package = false)
{
if (!is_callable($callback)) {
$callback = false;
* @see PEAR_ERRORSTACK_PUSHANDLOG, PEAR_ERRORSTACK_PUSH, PEAR_ERRORSTACK_LOG
* @see staticPopCallback(), pushCallback()
* @param string|array $cb
- * @static
*/
- function staticPushCallback($cb)
+ public static function staticPushCallback($cb)
{
array_push($GLOBALS['_PEAR_ERRORSTACK_OVERRIDE_CALLBACK'], $cb);
}
* Remove a temporary overriding error callback
* @see staticPushCallback()
* @return array|string|false
- * @static
*/
- function staticPopCallback()
+ public static function staticPopCallback()
{
$ret = array_pop($GLOBALS['_PEAR_ERRORSTACK_OVERRIDE_CALLBACK']);
if (!is_array($GLOBALS['_PEAR_ERRORSTACK_OVERRIDE_CALLBACK'])) {
* to find error context
* @return PEAR_Error|array if compatibility mode is on, a PEAR_Error is also
* thrown. see docs for {@link push()}
- * @static
*/
- function staticPush($package, $code, $level = 'error', $params = array(),
- $msg = false, $repackage = false, $backtrace = false)
- {
+ public static function staticPush(
+ $package, $code, $level = 'error', $params = array(),
+ $msg = false, $repackage = false, $backtrace = false
+ ) {
$s = &PEAR_ErrorStack::singleton($package);
if ($s->_contextCallback) {
if (!$backtrace) {
* @param string|false Package name to check for errors
* @param string Level name to check for a particular severity
* @return boolean
- * @static
*/
- function staticHasErrors($package = false, $level = false)
+ public static function staticHasErrors($package = false, $level = false)
{
if ($package) {
if (!isset($GLOBALS['_PEAR_ERRORSTACK_SINGLETON'][$package])) {
* @param boolean $merge Set to return a flat array, not organized by package
* @param array $sortfunc Function used to sort a merged array - default
* sorts by time, and should be good for most cases
- * @static
+ *
* @return array
*/
- function staticGetErrors($purge = false, $level = false, $merge = false,
- $sortfunc = array('PEAR_ErrorStack', '_sortErrors'))
- {
+ public static function staticGetErrors(
+ $purge = false, $level = false, $merge = false,
+ $sortfunc = array('PEAR_ErrorStack', '_sortErrors')
+ ) {
$ret = array();
if (!is_callable($sortfunc)) {
$sortfunc = array('PEAR_ErrorStack', '_sortErrors');
* Error sorting function, sorts by time
* @access private
*/
- function _sortErrors($a, $b)
+ public static function _sortErrors($a, $b)
{
if ($a['time'] == $b['time']) {
return 0;
* @param unused
* @param integer backtrace frame.
* @param array Results of debug_backtrace()
- * @static
*/
- function getFileLine($code, $params, $backtrace = null)
+ public static function getFileLine($code, $params, $backtrace = null)
{
if ($backtrace === null) {
return false;
* @param PEAR_ErrorStack
* @param array
* @param string|false Pre-generated error message template
- * @static
+ *
* @return string
*/
- function getErrorMessage(&$stack, $err, $template = false)
+ public static function getErrorMessage(&$stack, $err, $template = false)
{
if ($template) {
$mainmsg = $template;