You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
thrownewSyntaxError(\sprintf('Positional arguments cannot be used after named arguments for %s "%s".', $this->type, $this->name), $this->node->getTemplateLine(), $this->node->getSourceContext());
49
+
thrownewSyntaxError(\sprintf('Positional arguments cannot be used after named arguments for %s "%s".', $this->twigCallable->getType(), $this->twigCallable->getName()), $this->node->getTemplateLine(), $this->node->getSourceContext());
61
50
}
62
51
63
52
$extractedArguments[$name] = $node;
64
53
}
65
54
66
55
if (!$named && !$this->twigCallable->isVariadic()) {
if (\count($extractedArguments) < $rc->getReflector()->getNumberOfRequiredParameters() - $min) {
69
-
thrownewSyntaxError(\sprintf('Value for argument "%s" is required for %s "%s".', $rc->getReflector()->getParameters()[$min + \count($extractedArguments)]->getName(), $this->type, $this->name), $this->node->getTemplateLine(), $this->node->getSourceContext());
57
+
if (\count($extractedArguments) < $this->rc->getReflector()->getNumberOfRequiredParameters() - $min) {
58
+
thrownewSyntaxError(\sprintf('Value for argument "%s" is required for %s "%s".', $this->rc->getReflector()->getParameters()[$min + \count($extractedArguments)]->getName(), $this->twigCallable->getType(), $this->twigCallable->getName()), $this->node->getTemplateLine(), $this->node->getSourceContext());
70
59
}
71
60
72
61
return$extractedArguments;
73
62
}
74
63
75
64
if (!$callable = $this->twigCallable->getCallable()) {
76
65
if ($named) {
77
-
thrownewSyntaxError(\sprintf('Named arguments are not supported for %s "%s".', $this->type, $this->name));
66
+
thrownewSyntaxError(\sprintf('Named arguments are not supported for %s "%s".', $this->twigCallable->getType(), $this->twigCallable->getName()));
78
67
}
79
68
80
-
thrownewSyntaxError(\sprintf('Arbitrary positional arguments are not supported for %s "%s".', $this->type, $this->name));
69
+
thrownewSyntaxError(\sprintf('Arbitrary positional arguments are not supported for %s "%s".', $this->twigCallable->getType(), $this->twigCallable->getName()));
@@ -100,13 +89,13 @@ public function extractArguments(Node $arguments): array
100
89
101
90
if (\array_key_exists($name, $extractedArguments)) {
102
91
if (\array_key_exists($pos, $extractedArguments)) {
103
-
thrownewSyntaxError(\sprintf('Argument "%s" is defined twice for %s "%s".', $name, $this->type, $this->name), $this->node->getTemplateLine(), $this->node->getSourceContext());
92
+
thrownewSyntaxError(\sprintf('Argument "%s" is defined twice for %s "%s".', $name, $this->twigCallable->getType(), $this->twigCallable->getName()), $this->node->getTemplateLine(), $this->node->getSourceContext());
104
93
}
105
94
106
95
if (\count($missingArguments)) {
107
96
thrownewSyntaxError(\sprintf(
108
97
'Argument "%s" could not be assigned for %s "%s(%s)" because it is mapped to an internal PHP function which cannot determine default value for optional argument%s "%s".',
@@ -129,7 +118,7 @@ public function extractArguments(Node $arguments): array
129
118
130
119
$missingArguments[] = $name;
131
120
} else {
132
-
thrownewSyntaxError(\sprintf('Value for argument "%s" is required for %s "%s".', $name, $this->type, $this->name), $this->node->getTemplateLine(), $this->node->getSourceContext());
121
+
thrownewSyntaxError(\sprintf('Value for argument "%s" is required for %s "%s".', $name, $this->twigCallable->getType(), $this->twigCallable->getName()), $this->node->getTemplateLine(), $this->node->getSourceContext());
133
122
}
134
123
}
135
124
@@ -162,7 +151,7 @@ public function extractArguments(Node $arguments): array
@@ -208,7 +195,7 @@ private function getCallableParameters(ReflectionCallable $rc): array
208
195
array_pop($parameters);
209
196
$isPhpVariadic = true;
210
197
} else {
211
-
thrownewSyntaxError(\sprintf('The last parameter of "%s" for %s "%s" must be an array with default value, eg. "array $arg = []".', $rc->getName(), $this->type, $this->name));
198
+
thrownewSyntaxError(\sprintf('The last parameter of "%s" for %s "%s" must be an array with default value, eg. "array $arg = []".', $this->rc->getName(), $this->twigCallable->getType(), $this->twigCallable->getName()));
@@ -40,7 +44,7 @@ public function __construct($callable, string $debugType = 'unknown', string $de
40
44
try {
41
45
$closure = \Closure::fromCallable($callable);
42
46
} catch (\TypeError$e) {
43
-
thrownew \LogicException(\sprintf('Callback for %s "%s" is not callable in the current scope.', $debugType, $debugName), 0, $e);
47
+
thrownew \LogicException(\sprintf('Callback for %s "%s" is not callable in the current scope.', $twigCallable->getType(), $twigCallable->getName()), 0, $e);
44
48
}
45
49
$this->reflector = $r = new \ReflectionFunction($closure);
@@ -73,19 +73,19 @@ public function testResolveArgumentsWithMissingValueForOptionalArgument()
73
73
$this->expectException(SyntaxError::class);
74
74
$this->expectExceptionMessage('Argument "case_sensitivity" could not be assigned for function "substr_compare(main_str, str, offset, length, case_sensitivity)" because it is mapped to an internal PHP function which cannot determine default value for optional argument "length".');
@@ -94,15 +94,15 @@ public function testResolveArgumentsWithMissingParameterForArbitraryArguments()
94
94
$this->expectException(\LogicException::class);
95
95
$this->expectExceptionMessage('The last parameter of "Twig\\Tests\\Node\\Expression\\CallTest::customFunctionWithArbitraryArguments" for function "foo" must be an array with default value, eg. "array $arg = []".');
@@ -111,7 +111,7 @@ public function testResolveArgumentsWithMissingParameterForArbitraryArgumentsOnF
111
111
$this->expectException(\LogicException::class);
112
112
$this->expectExceptionMessageMatches('#^The last parameter of "Twig\\\\Tests\\\\Node\\\\Expression\\\\custom_call_test_function" for function "foo" must be an array with default value, eg\\. "array \\$arg \\= \\[\\]"\\.$#');
@@ -120,7 +120,7 @@ public function testResolveArgumentsWithMissingParameterForArbitraryArgumentsOnO
120
120
$this->expectException(\LogicException::class);
121
121
$this->expectExceptionMessageMatches('#^The last parameter of "Twig\\\\Tests\\\\Node\\\\Expression\\\\CallableTestClass\\:\\:__invoke" for function "foo" must be an array with default value, eg\\. "array \\$arg \\= \\[\\]"\\.$#');
0 commit comments