From 91b6e2945aef0bd4d4e23bea42dbab53b82e5b4c Mon Sep 17 00:00:00 2001 From: Qiang Xue Date: Thu, 12 Sep 2013 20:10:06 -0400 Subject: [PATCH] Removed the support for calling anonymous function returned as a property value. --- framework/yii/base/Component.php | 12 ++---------- framework/yii/base/Object.php | 8 -------- tests/unit/framework/base/ObjectTest.php | 5 ----- 3 files changed, 2 insertions(+), 23 deletions(-) diff --git a/framework/yii/base/Component.php b/framework/yii/base/Component.php index f497a29f48..2ad2c9459e 100644 --- a/framework/yii/base/Component.php +++ b/framework/yii/base/Component.php @@ -179,9 +179,8 @@ class Component extends Object /** * Calls the named method which is not a class method. - * If the name refers to a component property whose value is - * an anonymous function, the method will execute the function. - * Otherwise, it will check if any attached behavior has + * + * This method will check if any attached behavior has * the named method and will execute it if available. * * Do not call this method directly as it is a PHP magic method that @@ -193,13 +192,6 @@ class Component extends Object */ public function __call($name, $params) { - if ($this->canGetProperty($name)) { - $func = $this->$name; - if ($func instanceof \Closure) { - return call_user_func_array($func, $params); - } - } - $this->ensureBehaviors(); foreach ($this->_behaviors as $object) { if ($object->hasMethod($name)) { diff --git a/framework/yii/base/Object.php b/framework/yii/base/Object.php index 0af3131202..55754de687 100644 --- a/framework/yii/base/Object.php +++ b/framework/yii/base/Object.php @@ -143,8 +143,6 @@ class Object implements Arrayable /** * Calls the named method which is not a class method. - * If the name refers to a component property whose value is - * an anonymous function, the method will execute the function. * * Do not call this method directly as it is a PHP magic method that * will be implicitly called when an unknown method is being invoked. @@ -155,12 +153,6 @@ class Object implements Arrayable */ public function __call($name, $params) { - if ($this->canGetProperty($name)) { - $func = $this->$name; - if ($func instanceof \Closure) { - return call_user_func_array($func, $params); - } - } throw new UnknownMethodException('Unknown method: ' . get_class($this) . "::$name()"); } diff --git a/tests/unit/framework/base/ObjectTest.php b/tests/unit/framework/base/ObjectTest.php index 933b721078..d6b95e595f 100644 --- a/tests/unit/framework/base/ObjectTest.php +++ b/tests/unit/framework/base/ObjectTest.php @@ -134,11 +134,6 @@ class ObjectTest extends TestCase $this->assertEquals('new text', $this->object->object->text); } - public function testAnonymousFunctionProperty() - { - $this->assertEquals(2, $this->object->execute(1)); - } - public function testConstruct() { $object = new NewObject(array('text' => 'test text'));