Refactor code

This commit is contained in:
Fabien Potencier
2024-10-25 07:35:14 +02:00
parent f3db1d1a0c
commit 89fdc7d31d
9 changed files with 38 additions and 30 deletions
+3 -3
View File
@@ -533,7 +533,7 @@ class ExpressionParser
public function getFunctionNode($name, $line)
{
if (null !== $alias = $this->parser->getImportedSymbol('function', $name)) {
return new MacroReferenceExpression(new TemplateVariable($alias['node']->getAttribute('name'), $line), $alias['name'], $this->createArguments($line), $line);
return new MacroReferenceExpression($alias['node']->getNode('var'), $alias['name'], $this->createArguments($line), $line);
}
$args = $this->parseOnlyArguments();
@@ -750,7 +750,7 @@ class ExpressionParser
}
if ('defined' === $test->getName() && $node instanceof NameExpression && null !== $alias = $this->parser->getImportedSymbol('function', $node->getAttribute('name'))) {
$node = new MacroReferenceExpression(new TemplateVariable($alias['node']->getAttribute('name'), $node->getTemplateLine()), $alias['name'], new ArrayExpression([], $node->getTemplateLine()), $node->getTemplateLine());
$node = new MacroReferenceExpression($alias['node']->getNode('var'), $alias['name'], new ArrayExpression([], $node->getTemplateLine()), $node->getTemplateLine());
}
$ready = $test instanceof TwigTest;
@@ -957,7 +957,7 @@ class ExpressionParser
$node instanceof NameExpression
&&
(
null !== $this->parser->getImportedSymbol('template', (new TemplateVariable($node->getAttribute('name'), $node->getTemplateLine()))->getAttribute('name'))
null !== $this->parser->getImportedSymbol('template', $node->getAttribute('name'))
||
'_self' === $node->getAttribute('name') && $attribute instanceof ConstantExpression
)