PEAR is discontinued

This is a static archive preserving historical releases and metadata. No new packages or updates will be published. For updates to existing packages, or to publish new packages, please use Composer and Packagist.

Home » PEAR » PEAR » Bug #2238

ErrorStack: request for new static methods

Details

Request #2238ErrorStack: request for new static methods
Submitted2004-08-27 12:57 UTC
Fromroehr at zilleon dot com
Assignedcellog
StatusClosed
PackagePEAR
PHP Version4.3.8
OSirrelevant
Roadmaps(Not assigned)

Comments

[2004-08-27 12:57 UTC] roehr at zilleon dot com

Description:
------------
Hi Greg,

first of all a big thanks for your fantastic ErrorStack package!

I prefer using the static methods and would like to see some convenience methods added to handle single stacks:

Reproduce code:
---------------
// returns errors of a specific stack
// could also be called staticGetPackageErrors()
function staticGetStackErrors($package)
{
$allErrors = PEAR_ErrorStack::staticGetErrors();
return (isset($allErrors[$package])) ? $allErrors[$package] : array();
}

// determine whether there are errors on a specific stack
// could also be called staticHasPackageErrors()
function staticHasStackErrors($package)
{
if (isset($GLOBALS['_PEAR_ERRORSTACK_SINGLETON'][$package]) && $GLOBALS['_PEAR_ERRORSTACK_SINGLETON'][$package]->hasErrors())
return true;
}

return false;
}

// counterpart to staticPush()
function staticPop($package)
{
$stack = &PEAR_ErrorStack::singleton($package);
// array_shift() instead of array_pop() because the stacks are upside-down
return array_shift($stack->_errors);
}

I think they would be a valuable asset and should not be too much work to integrate. Thank you very much for having a look!

Best regards, Torsten Roehr

[2004-08-30 13:25 UTC] roehr at zilleon dot com

Please ignore the first of my method requests (staticGetStackErrors()) - this is what the singleton already does.