From 540f7ae44fbb977f7c2f169df5ce59e0de958e40 Mon Sep 17 00:00:00 2001 From: Mike Cao Date: Thu, 31 Mar 2011 10:10:23 +0000 Subject: [PATCH] Object can use foreach in PHP 5 --- flight/Flight.php | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/flight/Flight.php b/flight/Flight.php index 1bd5b08..c9253a1 100644 --- a/flight/Flight.php +++ b/flight/Flight.php @@ -198,8 +198,8 @@ class Flight { /** * Invokes a method. * - * @param mixed $func Class method as either an array or string - * @param array $params Class initialization parameters + * @param mixed $func Class method + * @param array $params Class method parameters */ public static function invokeMethod($func, array &$params = array()) { list($class, $method) = $func; @@ -282,17 +282,11 @@ class Flight { */ public static function set($key, $value = null) { // If key is an array, save each key value pair - if (is_array($key)) { + if (is_array($key) || is_object($key)) { foreach ($key as $k => $v) { self::$vars[$k] = $v; } } - // If key is an object, save each property - else if (is_object($key)) { - foreach (get_object_vars($key) as $k => $v) { - self::$vars[$k] = $v; - } - } else if (is_string($key)) { self::$vars[$key] = $value; }