mirror of
https://github.com/twigphp/Twig.git
synced 2026-10-23 12:15:17 +00:00
Merge branch '3.x' into 4.x
* 3.x: Deprecate Twig\ExpressionParser::parseOnlyArguments() and Twig\ExpressionParser::parseArguments()
This commit is contained in:
@@ -494,7 +494,7 @@ class ExpressionParser
|
||||
return new MacroReferenceExpression($alias['node']->getNode('var'), $alias['name'], $this->createArguments($line), $line);
|
||||
}
|
||||
|
||||
$args = $this->parseOnlyArguments();
|
||||
$args = $this->parseNamedArguments();
|
||||
$function = $this->getFunction($name, $line);
|
||||
|
||||
if ($function->getParserCallable()) {
|
||||
@@ -531,7 +531,7 @@ class ExpressionParser
|
||||
if (!$this->parser->getStream()->test(Token::PUNCTUATION_TYPE, '(')) {
|
||||
$arguments = new EmptyNode();
|
||||
} else {
|
||||
$arguments = $this->parseOnlyArguments();
|
||||
$arguments = $this->parseNamedArguments();
|
||||
}
|
||||
|
||||
$filter = $this->getFilter($token->getValue(), $token->getLine());
|
||||
@@ -554,6 +554,8 @@ class ExpressionParser
|
||||
* @return Node
|
||||
*
|
||||
* @throws SyntaxError
|
||||
*
|
||||
* @deprecated since Twig 3.19 Use parseNamedArguments() instead
|
||||
*/
|
||||
public function parseArguments()
|
||||
{
|
||||
@@ -648,7 +650,7 @@ class ExpressionParser
|
||||
|
||||
$arguments = null;
|
||||
if ($stream->test(Token::PUNCTUATION_TYPE, '(')) {
|
||||
$arguments = $this->parseOnlyArguments();
|
||||
$arguments = $this->parseNamedArguments();
|
||||
} elseif ($test->hasOneMandatoryArgument()) {
|
||||
$arguments = new Nodes([0 => $this->getPrimary()]);
|
||||
}
|
||||
@@ -746,14 +748,24 @@ class ExpressionParser
|
||||
private function createArguments(int $line): ArrayExpression
|
||||
{
|
||||
$arguments = new ArrayExpression([], $line);
|
||||
foreach ($this->parseOnlyArguments() as $k => $n) {
|
||||
foreach ($this->parseNamedArguments() as $k => $n) {
|
||||
$arguments->addElement($n, new LocalVariable($k, $line));
|
||||
}
|
||||
|
||||
return $arguments;
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated since Twig 3.19 Use parseNamedArguments() instead
|
||||
*/
|
||||
public function parseOnlyArguments()
|
||||
{
|
||||
trigger_deprecation('twig/twig', '3.19', \sprintf('The "%s()" method is deprecated, use "%s::parseNamedArguments()" instead.', __METHOD__, __CLASS__));
|
||||
|
||||
return $this->parseNamedArguments();
|
||||
}
|
||||
|
||||
public function parseNamedArguments(): Nodes
|
||||
{
|
||||
$args = [];
|
||||
$stream = $this->parser->getStream();
|
||||
|
||||
Reference in New Issue
Block a user