diff --git a/src/Node/TransNode.php b/src/Node/TransNode.php index 1231d26..8cc2763 100644 --- a/src/Node/TransNode.php +++ b/src/Node/TransNode.php @@ -159,7 +159,8 @@ public function compile(Compiler $compiler) $compiler->raw('), array('); foreach ($vars as $var) { - if ($var->getAttribute('name') === 'count') { + $attributeName = $var->getAttribute('name'); + if ($attributeName === 'count') { $compiler ->string('%count%') ->raw(' => abs(') @@ -167,7 +168,7 @@ public function compile(Compiler $compiler) ->raw('), '); } else { $compiler - ->string('%' . $var->getAttribute('name') . '%') + ->string('%' . $attributeName . '%') ->raw(' => ') ->subcompile($var) ->raw(', '); @@ -233,8 +234,9 @@ protected function compileString(Node $body): array while ($n instanceof CheckToStringNode) { $n = $n->getNode('expr'); } - $msg .= sprintf('%%%s%%', $n->getAttribute('name')); - $vars[] = new NameExpression($n->getAttribute('name'), $n->getTemplateLine()); + $attributeName = $n->getAttribute('name'); + $msg .= sprintf('%%%s%%', $attributeName); + $vars[] = new NameExpression($attributeName, $n->getTemplateLine()); } else { $msg .= $node->getAttribute('data'); }