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

[TwigBridge]  Use constant var name to cache trans_default_domain expression result #57609

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 1, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@
*/
final class TranslationDefaultDomainNodeVisitor implements NodeVisitorInterface
{
private const INTERNAL_VAR_NAME = '__internal_trans_default_domain';

private Scope $scope;

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

return $node;
} else {
$var = $this->getVarName();
$name = new AssignNameExpression($var, $node->getTemplateLine());
$this->scope->set('domain', new NameExpression($var, $node->getTemplateLine()));
$name = new AssignNameExpression(self::INTERNAL_VAR_NAME, $node->getTemplateLine());
$this->scope->set('domain', new NameExpression(self::INTERNAL_VAR_NAME, $node->getTemplateLine()));

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

return false;
}

private function getVarName(): string
{
return \sprintf('__internal_%s', hash('xxh128', uniqid(mt_rand(), true)));
}
}
Morty Proxy This is a proxified and sanitized view of the page, visit original site.