From 6fa5a86dbff3a19c3a34c05fce1d027dc38e32fc Mon Sep 17 00:00:00 2001 From: skodak Date: Thu, 1 May 2008 21:14:22 +0000 Subject: [PATCH] MDL-14617 pre PHP5 function emulations gone --- lib/moodlelib.php | 65 ----------------------------------------------- 1 file changed, 65 deletions(-) diff --git a/lib/moodlelib.php b/lib/moodlelib.php index 37d3edd23b..a8767a6f04 100644 --- a/lib/moodlelib.php +++ b/lib/moodlelib.php @@ -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. -- 2.39.5