Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit ab116bb

Browse filesBrowse files
committed
Use constant var name to cache trans_default_domain expression result
1 parent 6c100c9 commit ab116bb
Copy full SHA for ab116bb

File tree

1 file changed

+4
-8
lines changed
Filter options

1 file changed

+4
-8
lines changed

‎src/Symfony/Bridge/Twig/NodeVisitor/TranslationDefaultDomainNodeVisitor.php

Copy file name to clipboardExpand all lines: src/Symfony/Bridge/Twig/NodeVisitor/TranslationDefaultDomainNodeVisitor.php
+4-8Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@
3030
*/
3131
final class TranslationDefaultDomainNodeVisitor implements NodeVisitorInterface
3232
{
33+
private const INTERNAL_VAR_NAME = '__internal_trans_default_domain';
34+
3335
private Scope $scope;
3436

3537
public function __construct()
@@ -49,9 +51,8 @@ public function enterNode(Node $node, Environment $env): Node
4951

5052
return $node;
5153
} else {
52-
$var = $this->getVarName();
53-
$name = new AssignNameExpression($var, $node->getTemplateLine());
54-
$this->scope->set('domain', new NameExpression($var, $node->getTemplateLine()));
54+
$name = new AssignNameExpression(self::INTERNAL_VAR_NAME, $node->getTemplateLine());
55+
$this->scope->set('domain', new NameExpression(self::INTERNAL_VAR_NAME, $node->getTemplateLine()));
5556

5657
return new SetNode(false, new Node([$name]), new Node([$node->getNode('expr')]), $node->getTemplateLine());
5758
}
@@ -111,9 +112,4 @@ private function isNamedArguments(Node $arguments): bool
111112

112113
return false;
113114
}
114-
115-
private function getVarName(): string
116-
{
117-
return \sprintf('__internal_%s', hash('xxh128', uniqid(mt_rand(), true)));
118-
}
119115
}

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.