Subversion Repositories Applications.papyrus

Rev

Rev 320 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 320 Rev 1173
Line 1... Line 1...
1
<?php
1
<?php
2
//
2
/**
3
// +--------------------------------------------------------------------+
-
 
4
// | PEAR, the PHP Extension and Application Repository                 |
3
 * PEAR, the PHP Extension and Application Repository
-
 
4
 *
5
// +--------------------------------------------------------------------+
5
 * PEAR class and PEAR_Error class
-
 
6
 *
6
// | Copyright (c) 1997-2004 The PHP Group                              |
7
 * PHP versions 4 and 5
7
// +--------------------------------------------------------------------+
-
 
-
 
8
 *
8
// | This source file is subject to version 3.0 of the PHP license,     |
9
 * LICENSE: This source file is subject to version 3.0 of the PHP license
9
// | that is bundled with this package in the file LICENSE, and is      |
-
 
10
// | available through the world-wide-web at the following url:         |
10
 * that is available through the world-wide-web at the following URI:
11
// | http://www.php.net/license/3_0.txt.                                |
11
 * http://www.php.net/license/3_0.txt.  If you did not receive a copy of
12
// | If you did not receive a copy of the PHP license and are unable to |
12
 * the PHP License and are unable to obtain it through the web, please
13
// | obtain it through the world-wide-web, please send a note to        |
-
 
14
// | license@php.net so we can mail you a copy immediately.             |
13
 * send a note to license@php.net so we can mail you a copy immediately.
-
 
14
 *
-
 
15
 * @category   pear
15
// +--------------------------------------------------------------------+
16
 * @package    PEAR
16
// | Authors: Sterling Hughes <sterling@php.net>                        |
17
 * @author     Sterling Hughes <sterling@php.net>
17
// |          Stig Bakken <ssb@php.net>                                 |
18
 * @author     Stig Bakken <ssb@php.net>
18
// |          Tomas V.V.Cox <cox@idecnet.com>                           |
19
 * @author     Tomas V.V.Cox <cox@idecnet.com>
-
 
20
 * @author     Greg Beaver <cellog@php.net>
-
 
21
 * @copyright  1997-2006 The PHP Group
19
// +--------------------------------------------------------------------+
22
 * @license    http://www.php.net/license/3_0.txt  PHP License 3.0
20
//
-
 
21
// $Id: PEAR.php,v 1.1 2005-03-30 08:50:19 jpm Exp $
23
 * @version    CVS: $Id: PEAR.php,v 1.2 2006-12-14 15:04:29 jp_milcent Exp $
-
 
24
 * @link       http://pear.php.net/package/PEAR
-
 
25
 * @since      File available since Release 0.1
22
//
26
 */
Line -... Line 27...
-
 
27
 
-
 
28
/**#@+
-
 
29
 * ERROR constants
23
 
30
 */
24
define('PEAR_ERROR_RETURN',     1);
31
define('PEAR_ERROR_RETURN',     1);
25
define('PEAR_ERROR_PRINT',      2);
32
define('PEAR_ERROR_PRINT',      2);
26
define('PEAR_ERROR_TRIGGER',    4);
33
define('PEAR_ERROR_TRIGGER',    4);
27
define('PEAR_ERROR_DIE',        8);
34
define('PEAR_ERROR_DIE',        8);
28
define('PEAR_ERROR_CALLBACK',  16);
35
define('PEAR_ERROR_CALLBACK',  16);
29
/**
36
/**
30
 * WARNING: obsolete
37
 * WARNING: obsolete
31
 * @deprecated
38
 * @deprecated
32
 */
39
 */
-
 
40
define('PEAR_ERROR_EXCEPTION', 32);
33
define('PEAR_ERROR_EXCEPTION', 32);
41
/**#@-*/
34
define('PEAR_ZE2', (function_exists('version_compare') &&
42
define('PEAR_ZE2', (function_exists('version_compare') &&
Line 35... Line 43...
35
                    version_compare(zend_version(), "2-dev", "ge")));
43
                    version_compare(zend_version(), "2-dev", "ge")));
36
 
44
 
Line 76... Line 84...
76
 * destructor, use error_log(), syslog() or something similar.
84
 * destructor, use error_log(), syslog() or something similar.
77
 *
85
 *
78
 * IMPORTANT! To use the emulated destructors you need to create the
86
 * IMPORTANT! To use the emulated destructors you need to create the
79
 * objects by reference: $obj =& new PEAR_child;
87
 * objects by reference: $obj =& new PEAR_child;
80
 *
88
 *
-
 
89
 * @category   pear
81
 * @since PHP 4.0.2
90
 * @package    PEAR
82
 * @author Stig Bakken <ssb@php.net>
91
 * @author     Stig Bakken <ssb@php.net>
-
 
92
 * @author     Tomas V.V. Cox <cox@idecnet.com>
-
 
93
 * @author     Greg Beaver <cellog@php.net>
-
 
94
 * @copyright  1997-2006 The PHP Group
-
 
95
 * @license    http://www.php.net/license/3_0.txt  PHP License 3.0
-
 
96
 * @version    Release: 1.4.11
83
 * @see http://pear.php.net/manual/
97
 * @link       http://pear.php.net/package/PEAR
-
 
98
 * @see        PEAR_Error
-
 
99
 * @since      Class available since PHP 4.0.2
-
 
100
 * @link        http://pear.php.net/manual/en/core.pear.php#core.pear.pear
84
 */
101
 */
85
class PEAR
102
class PEAR
86
{
103
{
87
    // {{{ properties
104
    // {{{ properties
Line 228... Line 245...
228
    * @param  mixed $args  The arguments to pass to the function
245
    * @param  mixed $args  The arguments to pass to the function
229
    * @return void
246
    * @return void
230
    */
247
    */
231
    function registerShutdownFunc($func, $args = array())
248
    function registerShutdownFunc($func, $args = array())
232
    {
249
    {
-
 
250
        // if we are called statically, there is a potential
-
 
251
        // that no shutdown func is registered.  Bug #6445
-
 
252
        if (!isset($GLOBALS['_PEAR_SHUTDOWN_REGISTERED'])) {
-
 
253
            register_shutdown_function("_PEAR_call_destructors");
-
 
254
            $GLOBALS['_PEAR_SHUTDOWN_REGISTERED'] = true;
-
 
255
        }
233
        $GLOBALS['_PEAR_shutdown_funcs'][] = array($func, $args);
256
        $GLOBALS['_PEAR_shutdown_funcs'][] = array($func, $args);
234
    }
257
    }
Line 235... Line 258...
235
 
258
 
236
    // }}}
259
    // }}}
Line 490... Line 513...
490
     * @access public
513
     * @access public
491
     * @return object   a PEAR error object
514
     * @return object   a PEAR error object
492
     * @see PEAR::setErrorHandling
515
     * @see PEAR::setErrorHandling
493
     * @since PHP 4.0.5
516
     * @since PHP 4.0.5
494
     */
517
     */
495
    function raiseError($message = null,
518
    function &raiseError($message = null,
496
                         $code = null,
519
                         $code = null,
497
                         $mode = null,
520
                         $mode = null,
498
                         $options = null,
521
                         $options = null,
499
                         $userinfo = null,
522
                         $userinfo = null,
500
                         $error_class = null,
523
                         $error_class = null,
Line 535... Line 558...
535
            $ec = $this->_error_class;
558
            $ec = $this->_error_class;
536
        } else {
559
        } else {
537
            $ec = 'PEAR_Error';
560
            $ec = 'PEAR_Error';
538
        }
561
        }
539
        if ($skipmsg) {
562
        if ($skipmsg) {
540
            return new $ec($code, $mode, $options, $userinfo);
563
            $a = &new $ec($code, $mode, $options, $userinfo);
-
 
564
            return $a;
541
        } else {
565
        } else {
542
            return new $ec($message, $code, $mode, $options, $userinfo);
566
            $a = &new $ec($message, $code, $mode, $options, $userinfo);
-
 
567
            return $a;
543
        }
568
        }
544
    }
569
    }
Line 545... Line 570...
545
 
570
 
546
    // }}}
571
    // }}}
Line 551... Line 576...
551
     * message, code and userinfo are enough.
576
     * message, code and userinfo are enough.
552
     *
577
     *
553
     * @param string $message
578
     * @param string $message
554
     *
579
     *
555
     */
580
     */
556
    function throwError($message = null,
581
    function &throwError($message = null,
557
                         $code = null,
582
                         $code = null,
558
                         $userinfo = null)
583
                         $userinfo = null)
559
    {
584
    {
560
        if (isset($this) && is_a($this, 'PEAR')) {
585
        if (isset($this) && is_a($this, 'PEAR')) {
561
            return $this->raiseError($message, $code, null, null, $userinfo);
586
            $a = &$this->raiseError($message, $code, null, null, $userinfo);
-
 
587
            return $a;
562
        } else {
588
        } else {
563
            return PEAR::raiseError($message, $code, null, null, $userinfo);
589
            $a = &PEAR::raiseError($message, $code, null, null, $userinfo);
-
 
590
            return $a;
564
        }
591
        }
565
    }
592
    }
Line 566... Line 593...
566
 
593
 
567
    // }}}
594
    // }}}
Line 767... Line 794...
767
        }
794
        }
768
    }
795
    }
769
}
796
}
Line 770... Line 797...
770
 
797
 
-
 
798
// }}}
-
 
799
/**
-
 
800
 * Standard PEAR error class for PHP 4
-
 
801
 *
771
// }}}
802
 * This class is supserseded by {@link PEAR_Exception} in PHP 5
-
 
803
 *
-
 
804
 * @category   pear
-
 
805
 * @package    PEAR
-
 
806
 * @author     Stig Bakken <ssb@php.net>
-
 
807
 * @author     Tomas V.V. Cox <cox@idecnet.com>
-
 
808
 * @author     Gregory Beaver <cellog@php.net>
-
 
809
 * @copyright  1997-2006 The PHP Group
-
 
810
 * @license    http://www.php.net/license/3_0.txt  PHP License 3.0
-
 
811
 * @version    Release: 1.4.11
-
 
812
 * @link       http://pear.php.net/manual/en/core.pear.pear-error.php
-
 
813
 * @see        PEAR::raiseError(), PEAR::throwError()
-
 
814
 * @since      Class available since PHP 4.0.2
772
 
815
 */
773
class PEAR_Error
816
class PEAR_Error
774
{
817
{
Line 775... Line 818...
775
    // {{{ properties
818
    // {{{ properties
Line 857... Line 900...
857
            if (is_callable($this->callback)) {
900
            if (is_callable($this->callback)) {
858
                call_user_func($this->callback, $this);
901
                call_user_func($this->callback, $this);
859
            }
902
            }
860
        }
903
        }
861
        if ($this->mode & PEAR_ERROR_EXCEPTION) {
904
        if ($this->mode & PEAR_ERROR_EXCEPTION) {
862
            trigger_error("PEAR_ERROR_EXCEPTION is obsolete, use class PEAR_ErrorStack for exceptions", E_USER_WARNING);
905
            trigger_error("PEAR_ERROR_EXCEPTION is obsolete, use class PEAR_Exception for exceptions", E_USER_WARNING);
863
            eval('$e = new Exception($this->message, $this->code);$e->PEAR_Error = $this;throw($e);');
906
            eval('$e = new Exception($this->message, $this->code);throw($e);');
864
        }
907
        }
865
    }
908
    }
Line 866... Line 909...
866
 
909
 
867
    // }}}
910
    // }}}
Line 973... Line 1016...
973
     * @return array Backtrace, or NULL if not available.
1016
     * @return array Backtrace, or NULL if not available.
974
     * @access public
1017
     * @access public
975
     */
1018
     */
976
    function getBacktrace($frame = null)
1019
    function getBacktrace($frame = null)
977
    {
1020
    {
-
 
1021
        if (defined('PEAR_IGNORE_BACKTRACE')) {
-
 
1022
            return null;
-
 
1023
        }
978
        if ($frame === null) {
1024
        if ($frame === null) {
979
            return $this->backtrace;
1025
            return $this->backtrace;
980
        }
1026
        }
981
        return $this->backtrace[$frame];
1027
        return $this->backtrace[$frame];
982
    }
1028
    }