From 84dd19d76f729e82f4d609fad2313a35dc15f45d Mon Sep 17 00:00:00 2001 From: Qiang Xue Date: Wed, 11 Sep 2013 13:42:34 -0400 Subject: [PATCH] Fixed the issue that Object/Component doesn't support using anonymous function as normal property values. --- framework/yii/base/Component.php | 5 ++--- framework/yii/base/Object.php | 5 ++--- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/framework/yii/base/Component.php b/framework/yii/base/Component.php index a7ddd29..f497a29 100644 --- a/framework/yii/base/Component.php +++ b/framework/yii/base/Component.php @@ -193,9 +193,8 @@ class Component extends Object */ public function __call($name, $params) { - $getter = 'get' . $name; - if (method_exists($this, $getter)) { - $func = $this->$getter(); + if ($this->canGetProperty($name)) { + $func = $this->$name; if ($func instanceof \Closure) { return call_user_func_array($func, $params); } diff --git a/framework/yii/base/Object.php b/framework/yii/base/Object.php index adbab9c..0af3131 100644 --- a/framework/yii/base/Object.php +++ b/framework/yii/base/Object.php @@ -155,9 +155,8 @@ class Object implements Arrayable */ public function __call($name, $params) { - $getter = 'get' . $name; - if (method_exists($this, $getter)) { - $func = $this->$getter(); + if ($this->canGetProperty($name)) { + $func = $this->$name; if ($func instanceof \Closure) { return call_user_func_array($func, $params); }