mirror of
https://github.com/twigphp/Twig.git
synced 2026-08-31 12:37:15 +00:00
Merge branch '3.x' into 4.x
* 3.x: Deprecate Twig\ExpressionParser::parseOnlyArguments() and Twig\ExpressionParser::parseArguments()
This commit is contained in:
@@ -32,7 +32,7 @@ class CacheTokenParser extends AbstractTokenParser
|
||||
while ($stream->test(Token::NAME_TYPE)) {
|
||||
$k = $stream->getCurrent()->getValue();
|
||||
$stream->next();
|
||||
$args = $expressionParser->parseArguments();
|
||||
$args = $expressionParser->parseNamedArguments();
|
||||
|
||||
switch ($k) {
|
||||
case 'ttl':
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
"require": {
|
||||
"php": ">=8.2",
|
||||
"symfony/cache": "^5.4|^6.4|^7.0",
|
||||
"twig/twig": "^3.13|^4.0"
|
||||
"twig/twig": "^3.19|^4.0"
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4" : { "Twig\\Extra\\Cache\\" : "" },
|
||||
|
||||
@@ -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