Home » PEAR » PEAR » Bug #2238
ErrorStack: request for new static methods
Details
| Request #2238 | ErrorStack: request for new static methods |
|---|---|
| Submitted | 2004-08-27 12:57 UTC |
| From | roehr at zilleon dot com |
| Assigned | cellog |
| Status | Closed |
| Package | PEAR |
| PHP Version | 4.3.8 |
| OS | irrelevant |
| 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.