Skip to content

Commit 6c98e45

Browse files
Merge branch '2.7' into 2.8
* 2.7: [travis] update to trusty Fix ArrayInput::toString() for VALUE_IS_ARRAY options/args [ExpressionLanguage] throws an exception on calling uncallable method
2 parents 2b8394d + 52ad769 commit 6c98e45

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

Node/GetAttrNode.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,8 +82,11 @@ public function evaluate($functions, $values)
8282
if (!is_object($obj)) {
8383
throw new \RuntimeException('Unable to get a property on a non-object.');
8484
}
85+
if (!is_callable($toCall = array($obj, $this->nodes['attribute']->attributes['value']))) {
86+
throw new \RuntimeException(sprintf('Unable to call method "%s" of object "%s".', $this->nodes['attribute']->attributes['value'], get_class($obj)));
87+
}
8588

86-
return call_user_func_array(array($obj, $this->nodes['attribute']->attributes['value']), $this->nodes['arguments']->evaluate($functions, $values));
89+
return call_user_func_array($toCall, $this->nodes['arguments']->evaluate($functions, $values));
8790

8891
case self::ARRAY_CALL:
8992
$array = $this->nodes['node']->evaluate($functions, $values);

Tests/ExpressionLanguageTest.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,16 @@ public function testRegisterAfterEval($registerCallback)
163163
$registerCallback($el);
164164
}
165165

166+
/**
167+
* @expectedException \RuntimeException
168+
* @expectedExceptionMessageRegExp /Unable to call method "\w+" of object "\w+"./
169+
*/
170+
public function testCallBadCallable()
171+
{
172+
$el = new ExpressionLanguage();
173+
$el->evaluate('foo.myfunction()', array('foo' => new \stdClass()));
174+
}
175+
166176
/**
167177
* @dataProvider getRegisterCallbacks
168178
* @expectedException \LogicException

0 commit comments

Comments
 (0)