fixed named args for static methods

This commit is contained in:
Kris Wallsmith
2015-01-29 16:46:20 +13:00
parent 6b434f4521
commit 7868fe838e
2 changed files with 13 additions and 0 deletions
+3
View File
@@ -120,6 +120,9 @@ abstract class Twig_Node_Expression_Call extends Twig_Node_Expression
} elseif (is_object($callable) && !$callable instanceof Closure) {
$r = new ReflectionObject($callable);
$r = $r->getMethod('__invoke');
} elseif (is_string($callable) && false !== strpos($callable, '::')) {
$parts = explode('::', $callable, 2);
$r = new ReflectionMethod($parts[0], $parts[1]);
} else {
$r = new ReflectionFunction($callable);
}
@@ -78,6 +78,16 @@ class Twig_Tests_Node_Expression_CallTest extends PHPUnit_Framework_TestCase
$this->assertEquals(array('arg1'), $node->getArguments(array($this, 'customFunction'), array('arg1' => 'arg1')));
}
public function testGetArgumentsForStaticMethod()
{
$node = new Twig_Tests_Node_Expression_Call(array(), array('type' => 'function', 'name' => 'custom_static_function'));
$this->assertEquals(array('arg1'), $node->getArguments(__CLASS__.'::customStaticFunction', array('arg1' => 'arg1')));
}
public static function customStaticFunction($arg1, $arg2 = 'default', $arg3 = array())
{
}
public function customFunction($arg1, $arg2 = 'default', $arg3 = array())
{
}