mirror of
https://github.com/twigphp/Twig.git
synced 2026-09-14 19:36:43 +00:00
fixed named args for static methods
This commit is contained in:
@@ -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())
|
||||
{
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user