[ExpressionLanguage] throws an exception on calling uncallable method
This commit is contained in:
parent
9c796b4e39
commit
c8b65aeb8b
|
@ -77,8 +77,11 @@ class GetAttrNode extends Node
|
|||
if (!is_object($obj)) {
|
||||
throw new \RuntimeException('Unable to get a property on a non-object.');
|
||||
}
|
||||
if (!is_callable($toCall = array($obj, $this->nodes['attribute']->attributes['value']))) {
|
||||
throw new \RuntimeException(sprintf('Unable to call method "%s" of object "%s".', $this->nodes['attribute']->attributes['value'], get_class($obj)));
|
||||
}
|
||||
|
||||
return call_user_func_array(array($obj, $this->nodes['attribute']->attributes['value']), $this->nodes['arguments']->evaluate($functions, $values));
|
||||
return call_user_func_array($toCall, $this->nodes['arguments']->evaluate($functions, $values));
|
||||
|
||||
case self::ARRAY_CALL:
|
||||
$array = $this->nodes['node']->evaluate($functions, $values);
|
||||
|
|
|
@ -163,6 +163,16 @@ class ExpressionLanguageTest extends TestCase
|
|||
$registerCallback($el);
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \RuntimeException
|
||||
* @expectedExceptionMessageRegExp /Unable to call method "\w+" of object "\w+"./
|
||||
*/
|
||||
public function testCallBadCallable()
|
||||
{
|
||||
$el = new ExpressionLanguage();
|
||||
$el->evaluate('foo.myfunction()', array('foo' => new \stdClass()));
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider getRegisterCallbacks
|
||||
* @expectedException \LogicException
|
||||
|
|
Reference in New Issue