Bearsampp 2026.9.23
Loading...
Searching...
No Matches
PEAR_ErrorStack Class Reference

Public Member Functions

 __construct ($package, $msgCallback=false, $contextCallback=false, $throwPEAR_Error=false)
 _handleError ($err)
 _log ($err)
 getErrorMessageTemplate ($code)
 getErrors ($purge=false, $level=false)
 getMessageCallback ()
 hasErrors ($level=false)
 pop ()
 popCallback ()
 push ($code, $level='error', $params=array(), $msg=false, $repackage=false, $backtrace=false)
 pushCallback ($cb)
 raiseError ()
 setContextCallback ($contextCallback)
 setErrorMessageTemplate ($template)
 setLogger (&$log)
 setMessageCallback ($msgCallback)

Static Public Member Functions

static _sortErrors ($a, $b)
static getErrorMessage (&$stack, $err, $template=false)
static getFileLine ($code, $params, $backtrace=null)
static setDefaultCallback ($callback=false, $package=false)
static setDefaultLogger (&$log)
static & singleton ( $package, $msgCallback=false, $contextCallback=false, $throwPEAR_Error=false, $stackClass='PEAR_ErrorStack')
static staticGetErrors ( $purge=false, $level=false, $merge=false, $sortfunc=array('PEAR_ErrorStack', '_sortErrors'))
static staticHasErrors ($package=false, $level=false)
static staticPop ($package)
static staticPopCallback ()
static staticPush ( $package, $code, $level='error', $params=array(), $msg=false, $repackage=false, $backtrace=false)
static staticPushCallback ($cb)

Data Fields

 $_compat = false
 $_contextCallback = false
 $_errorCallback = array()
 $_errorMsgs = array()
 $_errors = array()
 $_errorsByLevel = array()
 $_logger = false
 $_msgCallback = false
 $_package

Detailed Description

Definition at line 141 of file ErrorStack.php.

Constructor & Destructor Documentation

◆ __construct()

__construct ( $package,
$msgCallback = false,
$contextCallback = false,
$throwPEAR_Error = false )

Set up a new error stack

Parameters
string$packagename of the package this error stack represents
callback$msgCallbackcallback used for error message generation
callback$contextCallbackcallback used for context generation, defaults to getFileLine()
boolean$throwPEAR_Error

Definition at line 231 of file ErrorStack.php.

233 {
234 $this->_package = $package;
235 $this->setMessageCallback($msgCallback);
236 $this->setContextCallback($contextCallback);
237 $this->_compat = $throwPEAR_Error;
238 }

References setContextCallback(), and setMessageCallback().

Here is the call graph for this function:

Member Function Documentation

◆ _handleError()

_handleError ( $err)

Internal error handler for PEAR_ErrorStack class

Dies if the error is an exception (and would have died anyway) @access private

Definition at line 282 of file ErrorStack.php.

283 {
284 if ($err['level'] == 'exception') {
285 $message = $err['message'];
286 if (isset($_SERVER['REQUEST_URI'])) {
287 echo '<br />';
288 } else {
289 echo "\n";
290 }
291 var_dump($err['context']);
292 die($message);
293 }
294 }

◆ _log()

_log ( $err)

Log an error using PEAR::Log

Parameters
array$errError array
array$levelsError level => Log constant map @access protected

Definition at line 624 of file ErrorStack.php.

625 {
626 if ($this->_logger) {
627 $logger = &$this->_logger;
628 } else {
629 $logger = &$GLOBALS['_PEAR_ERRORSTACK_DEFAULT_LOGGER'];
630 }
631 if (is_a($logger, 'Log')) {
632 $levels = array(
633 'exception' => PEAR_LOG_CRIT,
634 'alert' => PEAR_LOG_ALERT,
635 'critical' => PEAR_LOG_CRIT,
636 'error' => PEAR_LOG_ERR,
637 'warning' => PEAR_LOG_WARNING,
638 'notice' => PEAR_LOG_NOTICE,
639 'info' => PEAR_LOG_INFO,
640 'debug' => PEAR_LOG_DEBUG);
641 if (isset($levels[$err['level']])) {
642 $level = $levels[$err['level']];
643 } else {
644 $level = PEAR_LOG_INFO;
645 }
646 $logger->log($err['message'], $level, $err);
647 } else { // support non-standard logs
648 call_user_func($logger, $err);
649 }
650 }
$GLOBALS['_PEAR_default_error_mode']
Definition PEAR.php:46

References $GLOBALS.

Referenced by push().

Here is the caller graph for this function:

◆ _sortErrors()

_sortErrors ( $a,
$b )
static

Error sorting function, sorts by time @access private

Definition at line 804 of file ErrorStack.php.

805 {
806 if ($a['time'] == $b['time']) {
807 return 0;
808 }
809 if ($a['time'] < $b['time']) {
810 return 1;
811 }
812 return -1;
813 }

◆ getErrorMessage()

getErrorMessage ( & $stack,
$err,
$template = false )
static

Standard error message generation callback

This method may also be called by a custom error message generator to fill in template values from the params array, simply set the third parameter to the error message template string to use

The special variable __msg% is reserved: use it only to specify where a message passed in by the user should be placed in the template, like so:

Error message: msg% - internal error

If the message passed like so:

$stack->push(ERROR_CODE, 'error', array(), 'server error 500');

The returned error message will be "Error message: server error 500 - internal error"

Parameters
PEAR_ErrorStack
array
string|falsePre-generated error message template
Returns
string

Definition at line 903 of file ErrorStack.php.

904 {
905 if ($template) {
906 $mainmsg = $template;
907 } else {
908 $mainmsg = $stack->getErrorMessageTemplate($err['code']);
909 }
910 $mainmsg = str_replace('%__msg%', $err['message'], $mainmsg);
911 if (is_array($err['params']) && count($err['params'])) {
912 foreach ($err['params'] as $name => $val) {
913 if (is_array($val)) {
914 // @ is needed in case $val is a multi-dimensional array
915 $val = @implode(', ', $val);
916 }
917 if (is_object($val)) {
918 if (method_exists($val, '__toString')) {
919 $val = $val->__toString();
920 } else {
922 'warning', array('obj' => get_class($val)),
923 'object %obj% passed into getErrorMessage, but has no __toString() method');
924 $val = 'Object';
925 }
926 }
927 $mainmsg = str_replace('%' . $name . '%', $val, $mainmsg);
928 }
929 }
930 return $mainmsg;
931 }
$stack
const PEAR_ERRORSTACK_ERR_OBJTOSTRING
static staticPush( $package, $code, $level='error', $params=array(), $msg=false, $repackage=false, $backtrace=false)

References $stack, PEAR_ERRORSTACK_ERR_OBJTOSTRING, and staticPush().

Here is the call graph for this function:

◆ getErrorMessageTemplate()

getErrorMessageTemplate ( $code)

Standard Error Message Template generator from code

Returns
string

Definition at line 937 of file ErrorStack.php.

938 {
939 if (!isset($this->_errorMsgs[$code])) {
940 return '%__msg%';
941 }
942 return $this->_errorMsgs[$code];
943 }

◆ getErrors()

getErrors ( $purge = false,
$level = false )

Retrieve all errors since last purge

Parameters
booleanset in order to empty the error stack
stringlevel name, to return only errors of a particular severity
Returns
array

Definition at line 710 of file ErrorStack.php.

711 {
712 if (!$purge) {
713 if ($level) {
714 if (!isset($this->_errorsByLevel[$level])) {
715 return array();
716 } else {
717 return $this->_errorsByLevel[$level];
718 }
719 } else {
720 return $this->_errors;
721 }
722 }
723 if ($level) {
724 $ret = $this->_errorsByLevel[$level];
725 foreach ($this->_errorsByLevel[$level] as $i => $unused) {
726 // entries are references to the $_errors array
727 $this->_errorsByLevel[$level][$i] = false;
728 }
729 // array_filter removes all entries === false
730 $this->_errors = array_filter($this->_errors);
731 unset($this->_errorsByLevel[$level]);
732 return $ret;
733 }
734 $ret = $this->_errors;
735 $this->_errors = array();
736 $this->_errorsByLevel = array();
737 return $ret;
738 }

◆ getFileLine()

getFileLine ( $code,
$params,
$backtrace = null )
static

Standard file/line number/function/class context callback

This function uses a backtrace generated from debug_backtrace() and so will not work at all in PHP < 4.3.0. The frame should reference the frame that contains the source of the error.

Returns
array|false either array('file' => file, 'line' => line, 'function' => function name, 'class' => class name) or if this doesn't work, then false
Parameters
unused
integerbacktrace frame.
arrayResults of debug_backtrace()

Definition at line 828 of file ErrorStack.php.

829 {
830 if ($backtrace === null) {
831 return false;
832 }
833 $frame = 0;
834 $functionframe = 1;
835 if (!isset($backtrace[1])) {
836 $functionframe = 0;
837 } else {
838 while (isset($backtrace[$functionframe]['function']) &&
839 $backtrace[$functionframe]['function'] == 'eval' &&
840 isset($backtrace[$functionframe + 1])) {
841 $functionframe++;
842 }
843 }
844 if (isset($backtrace[$frame])) {
845 if (!isset($backtrace[$frame]['file'])) {
846 $frame++;
847 }
848 $funcbacktrace = $backtrace[$functionframe];
849 $filebacktrace = $backtrace[$frame];
850 $ret = array('file' => $filebacktrace['file'],
851 'line' => $filebacktrace['line']);
852 // rearrange for eval'd code or create function errors
853 if (strpos($filebacktrace['file'], '(') &&
854 preg_match(';^(.*?)\‍((\d+)\‍) : (.*?)\\z;', $filebacktrace['file'],
855 $matches)) {
856 $ret['file'] = $matches[1];
857 $ret['line'] = $matches[2] + 0;
858 }
859 if (isset($funcbacktrace['function']) && isset($backtrace[1])) {
860 if ($funcbacktrace['function'] != 'eval') {
861 if ($funcbacktrace['function'] == '__lambda_func') {
862 $ret['function'] = 'create_function() code';
863 } else {
864 $ret['function'] = $funcbacktrace['function'];
865 }
866 }
867 }
868 if (isset($funcbacktrace['class']) && isset($backtrace[1])) {
869 $ret['class'] = $funcbacktrace['class'];
870 }
871 return $ret;
872 }
873 return false;
874 }

◆ getMessageCallback()

getMessageCallback ( )

Get an error code => error message mapping callback

This method returns the current callback that can be used to generate error messages

Returns
array|string|false Callback function/method or false if none

Definition at line 347 of file ErrorStack.php.

348 {
349 return $this->_msgCallback;
350 }

◆ hasErrors()

hasErrors ( $level = false)

Determine whether there are any errors on the stack

Parameters
string|arrayLevel name. Use to determine if any errors of level (string), or levels (array) have been pushed
Returns
boolean

Definition at line 695 of file ErrorStack.php.

696 {
697 if ($level) {
698 return isset($this->_errorsByLevel[$level]);
699 }
700 return count($this->_errors);
701 }

◆ pop()

pop ( )

Pop an error off of the error stack

Returns
false|array
Since
0.4alpha it is no longer possible to specify a specific error level to return - the last error pushed will be returned, instead

Definition at line 660 of file ErrorStack.php.

661 {
662 $err = @array_shift($this->_errors);
663 if (!is_null($err)) {
664 @array_pop($this->_errorsByLevel[$err['level']]);
665 if (!count($this->_errorsByLevel[$err['level']])) {
666 unset($this->_errorsByLevel[$err['level']]);
667 }
668 }
669 return $err;
670 }

◆ popCallback()

popCallback ( )

Remove a callback from the error callback stack

See also
pushCallback()
Returns
array|string|false

Definition at line 416 of file ErrorStack.php.

417 {
418 if (!count($this->_errorCallback)) {
419 return false;
420 }
421 return array_pop($this->_errorCallback);
422 }

Referenced by push().

Here is the caller graph for this function:

◆ push()

push ( $code,
$level = 'error',
$params = array(),
$msg = false,
$repackage = false,
$backtrace = false )

Add an error to the stack

If the message generator exists, it is called with 2 parameters.

  • the current Error Stack object
  • an array that is in the same format as an error. Available indices are 'code', 'package', 'time', 'params', 'level', and 'context'

Next, if the error should contain context information, this is handled by the context grabbing method. Finally, the error is pushed onto the proper error stack

Parameters
int$codePackage-specific error code
string$levelError level. This is NOT spell-checked
array$paramsassociative array of error parameters
string$msgError message, or a portion of it if the message is to be generated
array$repackageIf this error re-packages an error pushed by another package, place the array returned from pop() in this parameter
array$backtraceProtected parameter: use this to pass in the debug_backtrace() that should be used to find error context
Returns
PEAR_Error|array if compatibility mode is on, a PEAR_Error is also thrown. If a PEAR_Error is returned, the userinfo property is set to the following array:

array( 'code' => $code, 'params' => $params, 'package' => $this->_package, 'level' => $level, 'time' => time(), 'context' => $context, 'message' => $msg, //['repackage' => $err] repackaged error array/Exception class );

Normally, the previous array is returned.

Definition at line 493 of file ErrorStack.php.

495 {
496 $context = false;
497 // grab error context
498 if ($this->_contextCallback) {
499 if (!$backtrace) {
500 $backtrace = debug_backtrace();
501 }
502 $context = call_user_func($this->_contextCallback, $code, $params, $backtrace);
503 }
504
505 // save error
506 $time = explode(' ', microtime());
507 $time = $time[1] + $time[0];
508 $err = array(
509 'code' => $code,
510 'params' => $params,
511 'package' => $this->_package,
512 'level' => $level,
513 'time' => $time,
514 'context' => $context,
515 'message' => $msg,
516 );
517
518 if ($repackage) {
519 $err['repackage'] = $repackage;
520 }
521
522 // set up the error message, if necessary
523 if ($this->_msgCallback) {
524 $msg = call_user_func_array($this->_msgCallback,
525 array(&$this, $err));
526 $err['message'] = $msg;
527 }
528 $push = $log = true;
529 $die = false;
530 // try the overriding callback first
531 $callback = $this->staticPopCallback();
532 if ($callback) {
533 $this->staticPushCallback($callback);
534 }
535 if (!is_callable($callback)) {
536 // try the local callback next
537 $callback = $this->popCallback();
538 if (is_callable($callback)) {
539 $this->pushCallback($callback);
540 } else {
541 // try the default callback
542 $callback = isset($GLOBALS['_PEAR_ERRORSTACK_DEFAULT_CALLBACK'][$this->_package]) ?
543 $GLOBALS['_PEAR_ERRORSTACK_DEFAULT_CALLBACK'][$this->_package] :
544 $GLOBALS['_PEAR_ERRORSTACK_DEFAULT_CALLBACK']['*'];
545 }
546 }
547 if (is_callable($callback)) {
548 switch(call_user_func($callback, $err)){
550 return $err;
551 break;
553 $log = false;
554 break;
556 $push = false;
557 break;
559 $die = true;
560 break;
561 // anything else returned has the same effect as pushandlog
562 }
563 }
564 if ($push) {
565 array_unshift($this->_errors, $err);
566 if (!isset($this->_errorsByLevel[$err['level']])) {
567 $this->_errorsByLevel[$err['level']] = array();
568 }
569 $this->_errorsByLevel[$err['level']][] = &$this->_errors[0];
570 }
571 if ($log) {
572 if ($this->_logger || $GLOBALS['_PEAR_ERRORSTACK_DEFAULT_LOGGER']) {
573 $this->_log($err);
574 }
575 }
576 if ($die) {
577 die();
578 }
579 if ($this->_compat && $push) {
580 return $this->raiseError($msg, $code, null, null, $err);
581 }
582 return $err;
583 }
const PEAR_ERRORSTACK_DIE
const PEAR_ERRORSTACK_LOG
const PEAR_ERRORSTACK_PUSH
const PEAR_ERRORSTACK_IGNORE
static staticPopCallback()
static staticPushCallback($cb)

References $GLOBALS, _log(), PEAR_ERRORSTACK_DIE, PEAR_ERRORSTACK_IGNORE, PEAR_ERRORSTACK_LOG, PEAR_ERRORSTACK_PUSH, popCallback(), pushCallback(), raiseError(), staticPopCallback(), and staticPushCallback().

Here is the call graph for this function:

◆ pushCallback()

pushCallback ( $cb)

Set an error Callback 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 of the ERRORSTACK_* constants.

This functionality can be used to emulate PEAR's pushErrorHandling, and the PEAR_ERROR_CALLBACK mode, without affecting the integrity of the error stack or logging

See also
PEAR_ERRORSTACK_PUSHANDLOG, PEAR_ERRORSTACK_PUSH, PEAR_ERRORSTACK_LOG
popCallback()
Parameters
string | array$cb

Definition at line 406 of file ErrorStack.php.

407 {
408 array_push($this->_errorCallback, $cb);
409 }

Referenced by push().

Here is the caller graph for this function:

◆ raiseError()

raiseError ( )

emulate PEAR::raiseError()

Returns
PEAR_Error

Definition at line 970 of file ErrorStack.php.

971 {
972 require_once 'PEAR.php';
973 $args = func_get_args();
974 return call_user_func_array(array('PEAR', 'raiseError'), $args);
975 }

Referenced by push().

Here is the caller graph for this function:

◆ setContextCallback()

setContextCallback ( $contextCallback)

Set a callback that generates context information (location of error) for an error stack

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

Parameters
array|string|nullCallback function/method

Definition at line 377 of file ErrorStack.php.

378 {
379 if ($contextCallback === null) {
380 return $this->_contextCallback = false;
381 }
382 if (!$contextCallback) {
383 $this->_contextCallback = array(&$this, 'getFileLine');
384 } else {
385 if (is_callable($contextCallback)) {
386 $this->_contextCallback = $contextCallback;
387 }
388 }
389 }

Referenced by __construct().

Here is the caller graph for this function:

◆ setDefaultCallback()

setDefaultCallback ( $callback = false,
$package = false )
static

Sets a default callback to be used by all error stacks

This method sets the callback that can be used to generate error messages for a singleton

Parameters
array|stringCallback function/method
stringPackage name, or false for all packages

Definition at line 360 of file ErrorStack.php.

361 {
362 if (!is_callable($callback)) {
363 $callback = false;
364 }
365 $package = $package ? $package : '*';
366 $GLOBALS['_PEAR_ERRORSTACK_DEFAULT_CALLBACK'][$package] = $callback;
367 }

References $GLOBALS.

◆ setDefaultLogger()

setDefaultLogger ( & $log)
static

Set up a PEAR::Log object for all error stacks that don't have one

Parameters
Log$log

Definition at line 300 of file ErrorStack.php.

301 {
302 if (is_object($log) && method_exists($log, 'log') ) {
303 $GLOBALS['_PEAR_ERRORSTACK_DEFAULT_LOGGER'] = &$log;
304 } elseif (is_callable($log)) {
305 $GLOBALS['_PEAR_ERRORSTACK_DEFAULT_LOGGER'] = &$log;
306 }
307 }

References $GLOBALS.

◆ setErrorMessageTemplate()

setErrorMessageTemplate ( $template)

Set the Error Message Template array

The array format must be:

array(error code => 'message template',...)

Error message parameters passed into push() will be used as input for the error message. If the template is 'message foo% was bar', and the parameters are array('foo' => 'one', 'bar' => 'six'), the error message returned will be 'message one was six'

Returns
string

Definition at line 959 of file ErrorStack.php.

960 {
961 $this->_errorMsgs = $template;
962 }

◆ setLogger()

setLogger ( & $log)

Set up a PEAR::Log object for this error stack

Parameters
Log$log

Definition at line 313 of file ErrorStack.php.

314 {
315 if (is_object($log) && method_exists($log, 'log') ) {
316 $this->_logger = &$log;
317 } elseif (is_callable($log)) {
318 $this->_logger = &$log;
319 }
320 }

◆ setMessageCallback()

setMessageCallback ( $msgCallback)

Set an error code => error message mapping callback

This method sets the callback that can be used to generate error messages for any instance

Parameters
array|stringCallback function/method

Definition at line 329 of file ErrorStack.php.

330 {
331 if (!$msgCallback) {
332 $this->_msgCallback = array(&$this, 'getErrorMessage');
333 } else {
334 if (is_callable($msgCallback)) {
335 $this->_msgCallback = $msgCallback;
336 }
337 }
338 }

Referenced by __construct().

Here is the caller graph for this function:

◆ singleton()

& singleton ( $package,
$msgCallback = false,
$contextCallback = false,
$throwPEAR_Error = false,
$stackClass = 'PEAR_ErrorStack' )
static

Return a single error stack for this package.

Note that all parameters are ignored if the stack for package $package has already been instantiated

Parameters
string$packagename of the package this error stack represents
callback$msgCallbackcallback used for error message generation
callback$contextCallbackcallback used for context generation, defaults to getFileLine()
boolean$throwPEAR_Error
string$stackClassclass to instantiate
Returns
PEAR_ErrorStack

Definition at line 254 of file ErrorStack.php.

257 {
258 if (isset($GLOBALS['_PEAR_ERRORSTACK_SINGLETON'][$package])) {
259 return $GLOBALS['_PEAR_ERRORSTACK_SINGLETON'][$package];
260 }
261 if (!class_exists($stackClass)) {
262 if (function_exists('debug_backtrace')) {
263 $trace = debug_backtrace();
264 }
266 'exception', array('stackclass' => $stackClass),
267 'stack class "%stackclass%" is not a valid class name (should be like PEAR_ErrorStack)',
268 false, $trace);
269 }
270 $GLOBALS['_PEAR_ERRORSTACK_SINGLETON'][$package] =
271 new $stackClass($package, $msgCallback, $contextCallback, $throwPEAR_Error);
272
273 return $GLOBALS['_PEAR_ERRORSTACK_SINGLETON'][$package];
274 }
const PEAR_ERRORSTACK_ERR_NONCLASS

References $GLOBALS, PEAR_ERRORSTACK_ERR_NONCLASS, and staticPush().

Referenced by staticPush().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ staticGetErrors()

staticGetErrors ( $purge = false,
$level = false,
$merge = false,
$sortfunc = array('PEAR_ErrorStack', '_sortErrors') )
static

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
Parameters
boolean$purgeSet to purge the error stack of existing errors
string$levelSet to a level name in order to retrieve only errors of a particular level
boolean$mergeSet to return a flat array, not organized by package
array$sortfuncFunction used to sort a merged array - default sorts by time, and should be good for most cases
Returns
array

Definition at line 776 of file ErrorStack.php.

779 {
780 $ret = array();
781 if (!is_callable($sortfunc)) {
782 $sortfunc = array('PEAR_ErrorStack', '_sortErrors');
783 }
784 foreach ($GLOBALS['_PEAR_ERRORSTACK_SINGLETON'] as $package => $obj) {
785 $test = $GLOBALS['_PEAR_ERRORSTACK_SINGLETON'][$package]->getErrors($purge, $level);
786 if ($test) {
787 if ($merge) {
788 $ret = array_merge($ret, $test);
789 } else {
790 $ret[$package] = $test;
791 }
792 }
793 }
794 if ($merge) {
795 usort($ret, $sortfunc);
796 }
797 return $ret;
798 }

References $GLOBALS.

◆ staticHasErrors()

staticHasErrors ( $package = false,
$level = false )
static

Determine whether there are any errors on a single error stack, or on any error stack

The optional parameter can be used to test the existence of any errors without the need of singleton instantiation

Parameters
string|falsePackage name to check for errors
stringLevel name to check for a particular severity
Returns
boolean

Definition at line 749 of file ErrorStack.php.

750 {
751 if ($package) {
752 if (!isset($GLOBALS['_PEAR_ERRORSTACK_SINGLETON'][$package])) {
753 return false;
754 }
755 return $GLOBALS['_PEAR_ERRORSTACK_SINGLETON'][$package]->hasErrors($level);
756 }
757 foreach ($GLOBALS['_PEAR_ERRORSTACK_SINGLETON'] as $package => $obj) {
758 if ($obj->hasErrors($level)) {
759 return true;
760 }
761 }
762 return false;
763 }

References $GLOBALS.

◆ staticPop()

staticPop ( $package)
static

Pop an error off of the error stack, static method

Parameters
stringpackage name
Returns
boolean
Since
PEAR1.5.0a1

Definition at line 679 of file ErrorStack.php.

680 {
681 if ($package) {
682 if (!isset($GLOBALS['_PEAR_ERRORSTACK_SINGLETON'][$package])) {
683 return false;
684 }
685 return $GLOBALS['_PEAR_ERRORSTACK_SINGLETON'][$package]->pop();
686 }
687 }

References $GLOBALS.

◆ staticPopCallback()

staticPopCallback ( )
static

Remove a temporary overriding error callback

See also
staticPushCallback()
Returns
array|string|false

Definition at line 443 of file ErrorStack.php.

444 {
445 $ret = array_pop($GLOBALS['_PEAR_ERRORSTACK_OVERRIDE_CALLBACK']);
446 if (!is_array($GLOBALS['_PEAR_ERRORSTACK_OVERRIDE_CALLBACK'])) {
447 $GLOBALS['_PEAR_ERRORSTACK_OVERRIDE_CALLBACK'] = array();
448 }
449 return $ret;
450 }

References $GLOBALS.

Referenced by push().

Here is the caller graph for this function:

◆ staticPush()

staticPush ( $package,
$code,
$level = 'error',
$params = array(),
$msg = false,
$repackage = false,
$backtrace = false )
static

Static version of push()

Parameters
string$packagePackage name this error belongs to
int$codePackage-specific error code
string$levelError level. This is NOT spell-checked
array$paramsassociative array of error parameters
string$msgError message, or a portion of it if the message is to be generated
array$repackageIf this error re-packages an error pushed by another package, place the array returned from pop() in this parameter
array$backtraceProtected parameter: use this to pass in the debug_backtrace() that should be used to find error context
Returns
PEAR_Error|array if compatibility mode is on, a PEAR_Error is also thrown. see docs for push()

Definition at line 603 of file ErrorStack.php.

606 {
607 $s = &PEAR_ErrorStack::singleton($package);
608 if ($s->_contextCallback) {
609 if (!$backtrace) {
610 if (function_exists('debug_backtrace')) {
611 $backtrace = debug_backtrace();
612 }
613 }
614 }
615 return $s->push($code, $level, $params, $msg, $repackage, $backtrace);
616 }

References singleton().

Referenced by getErrorMessage(), and singleton().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ staticPushCallback()

staticPushCallback ( $cb)
static

Set a temporary overriding error callback for every package error stack

Use this to temporarily disable all existing callbacks (can be used to emulate the @ operator, for instance)

See also
PEAR_ERRORSTACK_PUSHANDLOG, PEAR_ERRORSTACK_PUSH, PEAR_ERRORSTACK_LOG
staticPopCallback(), pushCallback()
Parameters
string | array$cb

Definition at line 433 of file ErrorStack.php.

434 {
435 array_push($GLOBALS['_PEAR_ERRORSTACK_OVERRIDE_CALLBACK'], $cb);
436 }

References $GLOBALS.

Referenced by push().

Here is the caller graph for this function:

Field Documentation

◆ $_compat

$_compat = false

Definition at line 174 of file ErrorStack.php.

◆ $_contextCallback

$_contextCallback = false

Definition at line 194 of file ErrorStack.php.

◆ $_errorCallback

$_errorCallback = array()

Definition at line 206 of file ErrorStack.php.

◆ $_errorMsgs

$_errorMsgs = array()

Definition at line 220 of file ErrorStack.php.

◆ $_errors

$_errors = array()

Definition at line 150 of file ErrorStack.php.

◆ $_errorsByLevel

$_errorsByLevel = array()

Definition at line 160 of file ErrorStack.php.

◆ $_logger

$_logger = false

Definition at line 213 of file ErrorStack.php.

◆ $_msgCallback

$_msgCallback = false

Definition at line 183 of file ErrorStack.php.

◆ $_package

$_package

Definition at line 167 of file ErrorStack.php.


The documentation for this class was generated from the following file:
  • E:/Bearsampp-development/sandbox/core/libs/php/pear/pear/PEAR/ErrorStack.php