mirror of
https://github.com/twigphp/Twig.git
synced 2026-09-13 19:06:40 +00:00
Fix exception message for static method and object without req. params.
This commit is contained in:
@@ -239,12 +239,12 @@ abstract class Twig_Node_Expression_Call extends Twig_Node_Expression
|
||||
if ($argument && $argument->isArray() && $argument->isDefaultValueAvailable() && array() === $argument->getDefaultValue()) {
|
||||
array_pop($parameters);
|
||||
} else {
|
||||
$callableName = $r->name;
|
||||
if ($r->getDeclaringClass()) {
|
||||
$callableName = $r->getDeclaringClass()->name.'::'.$callableName;
|
||||
}
|
||||
|
||||
throw new LogicException(sprintf('The last parameter of "%s" for %s "%s" must be an array with default value, eg. "array $arg = array()".', $callableName, $this->getAttribute('type'), $this->getAttribute('name')));
|
||||
throw new LogicException(sprintf(
|
||||
'The last parameter of "%s" for %s "%s" must be an array with default value, eg. "array $arg = array()".',
|
||||
$r instanceof ReflectionMethod ? $r->getDeclaringClass()->name.'::'.$r->name : $r->name,
|
||||
$this->getAttribute('type'),
|
||||
$this->getAttribute('name')
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -105,6 +105,26 @@ class Twig_Tests_Node_Expression_CallTest extends PHPUnit_Framework_TestCase
|
||||
public function customFunctionWithArbitraryArguments()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException LogicException
|
||||
* @expectedExceptionMessageRegExp #^The last parameter of "custom_Twig_Tests_Node_Expression_CallTest_function" for function "foo" must be an array with default value, eg\. "array \$arg \= array\(\)"\.$#
|
||||
*/
|
||||
public function testResolveArgumentsWithMissingParameterForArbitraryArgumentsOnFunction()
|
||||
{
|
||||
$node = new Twig_Tests_Node_Expression_Call(array(), array('type' => 'function', 'name' => 'foo', 'is_variadic' => true));
|
||||
$node->getArguments('custom_Twig_Tests_Node_Expression_CallTest_function', array());
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException LogicException
|
||||
* @expectedExceptionMessageRegExp #^The last parameter of "CallableTestClass\:\:__invoke" for function "foo" must be an array with default value, eg\. "array \$arg \= array\(\)"\.$#
|
||||
*/
|
||||
public function testResolveArgumentsWithMissingParameterForArbitraryArgumentsOnObject()
|
||||
{
|
||||
$node = new Twig_Tests_Node_Expression_Call(array(), array('type' => 'function', 'name' => 'foo', 'is_variadic' => true));
|
||||
$node->getArguments(new CallableTestClass(), array());
|
||||
}
|
||||
}
|
||||
|
||||
class Twig_Tests_Node_Expression_Call extends Twig_Node_Expression_Call
|
||||
@@ -114,3 +134,14 @@ class Twig_Tests_Node_Expression_Call extends Twig_Node_Expression_Call
|
||||
return parent::getArguments($callable, $arguments);
|
||||
}
|
||||
}
|
||||
|
||||
class CallableTestClass
|
||||
{
|
||||
public function __invoke($required)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
function custom_Twig_Tests_Node_Expression_CallTest_function($required)
|
||||
{
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user