From 3ac657996889b4894262d7625fe29781ad73aca2 Mon Sep 17 00:00:00 2001 From: Kijin Sung Date: Fri, 3 Apr 2015 16:28:46 +0900 Subject: [PATCH] Remove unnecessary use of anonymous functions --- classes/db/DB.class.php | 3 +-- classes/module/ModuleHandler.class.php | 5 ++--- config/func.inc.php | 17 +++++++---------- modules/editor/editor.model.php | 3 +-- 4 files changed, 11 insertions(+), 17 deletions(-) diff --git a/classes/db/DB.class.php b/classes/db/DB.class.php index af6f2f01d..c921a849d 100644 --- a/classes/db/DB.class.php +++ b/classes/db/DB.class.php @@ -328,8 +328,7 @@ class DB unset($oDB); require_once($class_file); - $tmp_fn = create_function('', "return new {$class_name}();"); - $oDB = $tmp_fn(); + $oDB = new $class_name(); if(!$oDB) { diff --git a/classes/module/ModuleHandler.class.php b/classes/module/ModuleHandler.class.php index 075afb838..b43e25df7 100644 --- a/classes/module/ModuleHandler.class.php +++ b/classes/module/ModuleHandler.class.php @@ -1060,14 +1060,13 @@ class ModuleHandler extends Handler return NULL; } - // Create an instance with eval function + // Create an instance require_once($class_file); if(!class_exists($instance_name, false)) { return NULL; } - $tmp_fn = create_function('', "return new {$instance_name}();"); - $oModule = $tmp_fn(); + $oModule = new $instance_name(); if(!is_object($oModule)) { return NULL; diff --git a/config/func.inc.php b/config/func.inc.php index d3fd2d83a..6040baa53 100644 --- a/config/func.inc.php +++ b/config/func.inc.php @@ -724,22 +724,19 @@ function zdate($str, $format = 'Y-m-d H:i:s', $conversion = TRUE) $month = (int) substr($str, 4, 2); $day = (int) substr($str, 6, 2); - // leading zero? - $lz = create_function('$n', 'return ($n>9?"":"0").$n;'); - $trans = array( 'Y' => $year, - 'y' => $lz($year % 100), - 'm' => $lz($month), + 'y' => sprintf('%02d', $year % 100), + 'm' => sprintf('%02d', $month), 'n' => $month, - 'd' => $lz($day), + 'd' => sprintf('%02d', $day), 'j' => $day, 'G' => $hour, - 'H' => $lz($hour), + 'H' => sprintf('%02d', $hour), 'g' => $hour % 12, - 'h' => $lz($hour % 12), - 'i' => $lz($min), - 's' => $lz($sec), + 'h' => sprintf('%02d', $hour % 12), + 'i' => sprintf('%02d', $min), + 's' => sprintf('%02d', $sec), 'M' => getMonthName($month), 'F' => getMonthName($month, FALSE) ); diff --git a/modules/editor/editor.model.php b/modules/editor/editor.model.php index 49f83f39c..d584f9ba3 100644 --- a/modules/editor/editor.model.php +++ b/modules/editor/editor.model.php @@ -550,8 +550,7 @@ class editorModel extends editor if(!file_exists($class_file)) return new Object(-1, sprintf(Context::getLang('msg_component_is_not_founded'), $component)); // Create an object after loading the class file require_once($class_file); - $tmp_fn = create_function('$seq,$path', "return new {$component}(\$seq,\$path);"); - $oComponent = $tmp_fn($editor_sequence, $class_path); + $oComponent = new $component($editor_sequence, $class_path); if(!$oComponent) return new Object(-1, sprintf(Context::getLang('msg_component_is_not_founded'), $component)); // Add configuration information $component_info = $this->getComponent($component, $site_srl);