Commit 91b6e294 by Qiang Xue

Removed the support for calling anonymous function returned as a property value.

parent a2b946e4
...@@ -179,9 +179,8 @@ class Component extends Object ...@@ -179,9 +179,8 @@ class Component extends Object
/** /**
* Calls the named method which is not a class method. * 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. * This method will check if any attached behavior has
* Otherwise, it will check if any attached behavior has
* the named method and will execute it if available. * the named method and will execute it if available.
* *
* Do not call this method directly as it is a PHP magic method that * Do not call this method directly as it is a PHP magic method that
...@@ -193,13 +192,6 @@ class Component extends Object ...@@ -193,13 +192,6 @@ class Component extends Object
*/ */
public function __call($name, $params) 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(); $this->ensureBehaviors();
foreach ($this->_behaviors as $object) { foreach ($this->_behaviors as $object) {
if ($object->hasMethod($name)) { if ($object->hasMethod($name)) {
......
...@@ -143,8 +143,6 @@ class Object implements Arrayable ...@@ -143,8 +143,6 @@ class Object implements Arrayable
/** /**
* Calls the named method which is not a class method. * 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 * 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. * will be implicitly called when an unknown method is being invoked.
...@@ -155,12 +153,6 @@ class Object implements Arrayable ...@@ -155,12 +153,6 @@ class Object implements Arrayable
*/ */
public function __call($name, $params) 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()"); throw new UnknownMethodException('Unknown method: ' . get_class($this) . "::$name()");
} }
......
...@@ -134,11 +134,6 @@ class ObjectTest extends TestCase ...@@ -134,11 +134,6 @@ class ObjectTest extends TestCase
$this->assertEquals('new text', $this->object->object->text); $this->assertEquals('new text', $this->object->object->text);
} }
public function testAnonymousFunctionProperty()
{
$this->assertEquals(2, $this->object->execute(1));
}
public function testConstruct() public function testConstruct()
{ {
$object = new NewObject(array('text' => 'test text')); $object = new NewObject(array('text' => 'test text'));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment