Restrict the callable lambda to object calls and anonymous functions.

This commit is contained in:
Damien Tournoud
2011-08-27 16:46:51 +02:00
parent 4bb4e970de
commit ac418ad876
2 changed files with 1 additions and 8 deletions
+1 -5
View File
@@ -847,17 +847,13 @@ class Mustache {
* 1. an anonymous function. * 1. an anonymous function.
* 2. an object and the name of a public function, i.e. `array($SomeObject, 'methodName')` * 2. an object and the name of a public function, i.e. `array($SomeObject, 'methodName')`
* 3. a class name and the name of a public static function, i.e. `array('SomeClass', 'methodName')` * 3. a class name and the name of a public static function, i.e. `array('SomeClass', 'methodName')`
* 4. a static function name in the form `'SomeClass::methodName'`
* *
* @access protected * @access protected
* @param mixed $var * @param mixed $var
* @return bool * @return bool
*/ */
protected function _varIsCallable($var) { protected function _varIsCallable($var) {
if (is_string($var) && (strpos($var, '::') == false)) { return !is_string($var) && is_callable($var);
return false;
}
return is_callable($var);
} }
} }
-3
View File
@@ -40,9 +40,6 @@ class MustacheHigherOrderSectionsTest extends PHPUnit_Framework_TestCase {
public function testStaticSectionCallback() { public function testStaticSectionCallback() {
$this->foo->trimmer = array(get_class($this->foo), 'staticTrim'); $this->foo->trimmer = array(get_class($this->foo), 'staticTrim');
$this->assertEquals($this->foo->name, $this->foo->render('{{#trimmer}} {{name}} {{/trimmer}}')); $this->assertEquals($this->foo->name, $this->foo->render('{{#trimmer}} {{name}} {{/trimmer}}'));
$this->foo->trimmer = 'Foo::staticTrim';
$this->assertEquals($this->foo->lorem, $this->foo->render('{{#trimmer}} {{lorem}} {{/trimmer}}'));
} }
public function testViewArraySectionCallback() { public function testViewArraySectionCallback() {