]> git.mjollnir.org Git - moodle.git/commitdiff
MDL-14617 pre PHP5 function emulations gone
authorskodak <skodak>
Thu, 1 May 2008 21:14:22 +0000 (21:14 +0000)
committerskodak <skodak>
Thu, 1 May 2008 21:14:22 +0000 (21:14 +0000)
lib/moodlelib.php

index 37d3edd23b116199141e5cce39bec9518c0a94d7..a8767a6f040e1a869e5f8985610e4f6f7e46c68b 100644 (file)
@@ -7417,71 +7417,6 @@ function cleanremoteaddr($addr) {
     return array_pop($goodmatches);
 }
 
-/**
- * The clone keyword is only supported from PHP 5 onwards.
- * The behaviour of $obj2 = $obj1 differs fundamentally
- * between PHP 4 and PHP 5. In PHP 4 a copy of $obj1 was
- * created, in PHP 5 $obj1 is referenced. To create a copy
- * in PHP 5 the clone keyword was introduced. This function
- * simulates this behaviour for PHP < 5.0.0.
- * See also: http://mjtsai.com/blog/2004/07/15/php-5-object-references/
- *
- * Modified 2005-09-29 by Eloy (from Julian Sedding proposal)
- * Found a better implementation (more checks and possibilities) from PEAR:
- * http://cvs.php.net/co.php/pear/PHP_Compat/Compat/Function/clone.php
- *
- * @param object $obj
- * @return object
- */
-if(!check_php_version('5.0.0')) {
-// the eval is needed to prevent PHP 5 from getting a parse error!
-eval('
-    function clone($obj) {
-    /// Sanity check
-        if (!is_object($obj)) {
-            user_error(\'clone() __clone method called on non-object\', E_USER_WARNING);
-            return;
-        }
-
-    /// Use serialize/unserialize trick to deep copy the object
-        $obj = unserialize(serialize($obj));
-
-    /// If there is a __clone method call it on the "new" class
-        if (method_exists($obj, \'__clone\')) {
-            $obj->__clone();
-        }
-
-        return $obj;
-    }
-
-    // Supply the PHP5 function scandir() to older versions.
-    function scandir($directory) {
-        $files = array();
-        if ($dh = opendir($directory)) {
-            while (($file = readdir($dh)) !== false) {
-               $files[] = $file;
-            }
-            closedir($dh);
-        }
-        return $files;
-    }
-
-    // Supply the PHP5 function array_combine() to older versions.
-    function array_combine($keys, $values) {
-        if (!is_array($keys) || !is_array($values) || count($keys) != count($values)) {
-            return false;
-        }
-        reset($values);
-        $result = array();
-        foreach ($keys as $key) {
-            $result[$key] = current($values);
-            next($values);
-        }
-        return $result;
-    }
-');
-}
-
 /**
  * This function will make a complete copy of anything it's given,
  * regardless of whether it's an object or not.