Changeset:
        d64c4a54c3a7
        
https://sourceforge.net/p/mrbs/hg-code/ci/d64c4a54c3a7566eefed0f171023da337003c92f
Author:
        Campbell Morrison <[email protected]>
Date:
        Thu Oct 01 15:11:47 2015 +0100
Log message:

Updated PEAR.php to latest version (1.10.0dev3) to avoid problems with PHP7

diffstat:

 web/PEAR.php |  587 +++++++++++++++++++++++++++++++++++-----------------------
 1 files changed, 353 insertions(+), 234 deletions(-)

diffs (truncated from 1070 to 300 lines):

diff -r ebfdfcd97573 -r d64c4a54c3a7 web/PEAR.php
--- a/web/PEAR.php      Thu Sep 24 20:11:45 2015 +0100
+++ b/web/PEAR.php      Thu Oct 01 15:11:47 2015 +0100
@@ -1,26 +1,26 @@
 <?php
-//
-// +--------------------------------------------------------------------+
-// | PEAR, the PHP Extension and Application Repository                 |
-// +--------------------------------------------------------------------+
-// | Copyright (c) 1997-2004 The PHP Group                              |
-// +--------------------------------------------------------------------+
-// | This source file is subject to version 2.0 of the PHP license,     |
-// | that is bundled with this package in the file LICENSE, and is      |
-// | available through the world-wide-web at the following url:         |
-// | http://www.php.net/license/3_0.txt.                                |
-// | If you did not receive a copy of the PHP license and are unable to |
-// | obtain it through the world-wide-web, please send a note to        |
-// | [email protected] so we can mail you a copy immediately.             |
-// +--------------------------------------------------------------------+
-// | Authors: Sterling Hughes <[email protected]>                        |
-// |          Stig Bakken <[email protected]>                                 |
-// |          Tomas V.V.Cox <[email protected]>                           |
-// +--------------------------------------------------------------------+
-//
-// $Id$
-//
+/**
+ * PEAR, the PHP Extension and Application Repository
+ *
+ * PEAR class and PEAR_Error class
+ *
+ * PHP versions 4 and 5
+ *
+ * @category   pear
+ * @package    PEAR
+ * @author     Sterling Hughes <[email protected]>
+ * @author     Stig Bakken <[email protected]>
+ * @author     Tomas V.V.Cox <[email protected]>
+ * @author     Greg Beaver <[email protected]>
+ * @copyright  1997-2010 The Authors
+ * @license    http://opensource.org/licenses/bsd-license.php New BSD License
+ * @link       http://pear.php.net/package/PEAR
+ * @since      File available since Release 0.1
+ */
 
+/**#@+
+ * ERROR constants
+ */
 define('PEAR_ERROR_RETURN',     1);
 define('PEAR_ERROR_PRINT',      2);
 define('PEAR_ERROR_TRIGGER',    4);
@@ -31,8 +31,7 @@
  * @deprecated
  */
 define('PEAR_ERROR_EXCEPTION', 32);
-define('PEAR_ZE2', (function_exists('version_compare') &&
-                    version_compare(zend_version(), "2-dev", "ge")));
+/**#@-*/
 
 if (substr(PHP_OS, 0, 3) == 'WIN') {
     define('OS_WINDOWS', true);
@@ -44,22 +43,13 @@
     define('PEAR_OS',    'Unix'); // blatant assumption
 }
 
-// instant backwards compatibility
-if (!defined('PATH_SEPARATOR')) {
-    if (OS_WINDOWS) {
-        define('PATH_SEPARATOR', ';');
-    } else {
-        define('PATH_SEPARATOR', ':');
-    }
-}
-
 $GLOBALS['_PEAR_default_error_mode']     = PEAR_ERROR_RETURN;
 $GLOBALS['_PEAR_default_error_options']  = E_USER_NOTICE;
 $GLOBALS['_PEAR_destructor_object_list'] = array();
 $GLOBALS['_PEAR_shutdown_funcs']         = array();
 $GLOBALS['_PEAR_error_handler_stack']    = array();
 
-ini_set('track_errors', true);
+@ini_set('track_errors', true);
 
 /**
  * Base class for other PEAR classes.  Provides rudimentary
@@ -78,14 +68,21 @@
  * IMPORTANT! To use the emulated destructors you need to create the
  * objects by reference: $obj =& new PEAR_child;
  *
- * @since PHP 4.0.2
- * @author Stig Bakken <[email protected]>
- * @see http://pear.php.net/manual/
+ * @category   pear
+ * @package    PEAR
+ * @author     Stig Bakken <[email protected]>
+ * @author     Tomas V.V. Cox <[email protected]>
+ * @author     Greg Beaver <[email protected]>
+ * @copyright  1997-2006 The PHP Group
+ * @license    http://opensource.org/licenses/bsd-license.php New BSD License
+ * @version    Release: 1.10.0dev3
+ * @link       http://pear.php.net/package/PEAR
+ * @see        PEAR_Error
+ * @since      Class available since PHP 4.0.2
+ * @link        http://pear.php.net/manual/en/core.pear.php#core.pear.pear
  */
 class PEAR
 {
-    // {{{ properties
-
     /**
      * Whether to enable internal debug messages.
      *
@@ -136,9 +133,17 @@
      */
     var $_expected_errors = array();
 
-    // }}}
-
-    // {{{ constructor
+    /**
+     * List of methods that can be called both statically and non-statically.
+     * @var array
+     */
+    protected static $bivalentMethods = array(
+        'setErrorHandling' => true,
+        'raiseError' => true,
+        'throwError' => true,
+        'pushErrorHandling' => true,
+        'popErrorHandling' => true,
+    );
 
     /**
      * Constructor.  Registers this object in
@@ -150,20 +155,26 @@
      * @access public
      * @return void
      */
-    function PEAR($error_class = null)
+    function __construct($error_class = null)
     {
-        $classname = get_class($this);
+        $classname = strtolower(get_class($this));
         if ($this->_debug) {
             print "PEAR constructor called, class=$classname\n";
         }
+
         if ($error_class !== null) {
             $this->_error_class = $error_class;
         }
-        while ($classname) {
+
+        while ($classname && strcasecmp($classname, "pear")) {
             $destructor = "_$classname";
             if (method_exists($this, $destructor)) {
                 global $_PEAR_destructor_object_list;
                 $_PEAR_destructor_object_list[] = &$this;
+                if (!isset($GLOBALS['_PEAR_SHUTDOWN_REGISTERED'])) {
+                    register_shutdown_function("_PEAR_call_destructors");
+                    $GLOBALS['_PEAR_SHUTDOWN_REGISTERED'] = true;
+                }
                 break;
             } else {
                 $classname = get_parent_class($classname);
@@ -171,8 +182,17 @@
         }
     }
 
-    // }}}
-    // {{{ destructor
+    /**
+     * Only here for backwards compatibility.
+     * E.g. Archive_Tar calls $this->PEAR() in its constructor.
+     *
+     * @param string $error_class Which class to use for error objects,
+     *                            defaults to PEAR_Error.
+     */
+    public function PEAR($error_class = null)
+    {
+        $this->__construct($error_class);
+    }
 
     /**
      * Destructor (the emulated type of...).  Does nothing right now,
@@ -187,12 +207,35 @@
      */
     function _PEAR() {
         if ($this->_debug) {
-            printf("PEAR destructor called, class=%s\n", get_class($this));
+            printf("PEAR destructor called, class=%s\n", 
strtolower(get_class($this)));
         }
     }
 
-    // }}}
-    // {{{ getStaticProperty()
+    public function __call($method, $arguments)
+    {
+        if (!isset(self::$bivalentMethods[$method])) {
+            trigger_error(
+                'Call to undefined method PEAR::' . $method . '()', 
E_USER_ERROR
+            );
+        }
+        return call_user_func_array(
+            array(get_class(), '_' . $method),
+            array_merge(array($this), $arguments)
+        );
+    }
+
+    public static function __callStatic($method, $arguments)
+    {
+        if (!isset(self::$bivalentMethods[$method])) {
+            trigger_error(
+                'Call to undefined method PEAR::' . $method . '()', 
E_USER_ERROR
+            );
+        }
+        return call_user_func_array(
+            array(get_class(), '_' . $method),
+            array_merge(array(null), $arguments)
+        );
+    }
 
     /**
     * If you have a class that's mostly/entirely static, and you need static
@@ -200,38 +243,45 @@
     * do this: $myVar = &PEAR::getStaticProperty('myclass', 'myVar');
     * You MUST use a reference, or they will not persist!
     *
-    * @access public
     * @param  string $class  The calling classname, to prevent clashes
     * @param  string $var    The variable to retrieve.
     * @return mixed   A reference to the variable. If not set it will be
     *                 auto initialised to NULL.
     */
-    function &getStaticProperty($class, $var)
+    public static function &getStaticProperty($class, $var)
     {
         static $properties;
+        if (!isset($properties[$class])) {
+            $properties[$class] = array();
+        }
+
+        if (!array_key_exists($var, $properties[$class])) {
+            $properties[$class][$var] = null;
+        }
+
         return $properties[$class][$var];
     }
 
-    // }}}
-    // {{{ registerShutdownFunc()
-
     /**
     * Use this function to register a shutdown method for static
     * classes.
     *
-    * @access public
     * @param  mixed $func  The function name (or array of class/method) to call
     * @param  mixed $args  The arguments to pass to the function
+    *
     * @return void
     */
-    function registerShutdownFunc($func, $args = array())
+    public static function registerShutdownFunc($func, $args = array())
     {
+        // if we are called statically, there is a potential
+        // that no shutdown func is registered.  Bug #6445
+        if (!isset($GLOBALS['_PEAR_SHUTDOWN_REGISTERED'])) {
+            register_shutdown_function("_PEAR_call_destructors");
+            $GLOBALS['_PEAR_SHUTDOWN_REGISTERED'] = true;
+        }
         $GLOBALS['_PEAR_shutdown_funcs'][] = array($func, $args);
     }
 
-    // }}}
-    // {{{ isError()
-
     /**
      * Tell whether a value is a PEAR error.
      *
@@ -240,26 +290,24 @@
      *                        only if $code is a string and
      *                        $obj->getMessage() == $code or
      *                        $code is an integer and $obj->getCode() == $code
-     * @access  public
+     *
      * @return  bool    true if parameter is an error
      */
-    function isError($data, $code = null)
+    public static function isError($data, $code = null)
     {
-        if (is_a($data, 'PEAR_Error')) {
-            if (is_null($code)) {
-                return true;
-            } elseif (is_string($code)) {
-                return $data->getMessage() == $code;
-            } else {
-                return $data->getCode() == $code;
-            }
+        if (!is_a($data, 'PEAR_Error')) {
+            return false;
         }

------------------------------------------------------------------------------
_______________________________________________
Mrbs-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mrbs-commits

Reply via email to