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];
        }
        if (!class_exists($stackClass)) {
            if (function_exists('debug_backtrace')) {
                $trace = debug_backtrace();
            }
            PEAR_ErrorStack::staticPush('PEAR_ErrorStack', PEAR_ERRORSTACK_ERR_NONCLASS,
                'exception', array('stackclass' => $stackClass),
                'stack class "%stackclass%" is not a valid class name (should be like PEAR_ErrorStack)',
                false, $trace);
        }
        $GLOBALS['_PEAR_ERRORSTACK_SINGLETON'][$package] =
            new $stackClass($package, $msgCallback, $contextCallback, $throwPEAR_Error);

        return $GLOBALS['_PEAR_ERRORSTACK_SINGLETON'][$package];
    }
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];
        }
        if (!class_exists($stackClass)) {
            if (function_exists('debug_backtrace')) {
                $trace = debug_backtrace();
            }
            PEAR_ErrorStack::staticPush('PEAR_ErrorStack', PEAR_ERRORSTACK_ERR_NONCLASS,
                'exception', array('stackclass' => $stackClass),
                'stack class "%stackclass%" is not a valid class name (should be like PEAR_ErrorStack)',
                false, $trace);
        }
        $GLOBALS['_PEAR_ERRORSTACK_SINGLETON'][$package] =
            new $stackClass($package, $msgCallback, $contextCallback, $throwPEAR_Error);

        return $GLOBALS['_PEAR_ERRORSTACK_SINGLETON'][$package];
    }
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 ] ; } if ( ! class_exists ( $ stackClass ) ) { if ( function_exists ( 'debug_backtrace' ) ) { $ trace = debug_backtrace ( ) ; } PEAR_ErrorStack :: staticPush ( 'PEAR_ErrorStack' , PEAR_ERRORSTACK_ERR_NONCLASS , 'exception' , array ( 'stackclass' => $ stackClass ) , 'stack class "%stackclass%" is not a valid class name (should be like PEAR_ErrorStack)' , false , $ trace ) ; } $ GLOBALS [ '_PEAR_ERRORSTACK_SINGLETON' ] [ $ package ] = new $ stackClass ( $ package , $ msgCallback , $ contextCallback , $ throwPEAR_Error ) ; return $ GLOBALS [ '_PEAR_ERRORSTACK_SINGLETON' ] [ $ package ] ; }
Return a single error stack for this package.

Note that all parameters are ignored if the stack for package $package
has already been instantiated
@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
@param string   $stackClass class to instantiate
@static
@return PEAR_ErrorStack
Return a single error stack for this package .