Skip to content

Commit

Permalink
bug #20253 [TwigBridge] Use non-deprecated Twig_Node::getTemplateLine…
Browse files Browse the repository at this point in the history
…() (fabpot)

This PR was merged into the 2.7 branch.

Discussion
----------

[TwigBridge] Use non-deprecated Twig_Node::getTemplateLine()

| Q             | A
| ------------- | ---
| Branch?       |2.7
| Bug fix?      | no
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | n/a
| License       | MIT
| Doc PR        | n/a

Commits
-------

bb791d0 [TwigBridge] Use non-deprecated Twig_Node::getTemplateLine()
  • Loading branch information
fabpot committed Oct 19, 2016
2 parents 8a420c5 + bb791d0 commit 8974d77
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion src/Symfony/Bridge/Twig/Node/SearchAndRenderBlockNode.php
Expand Up @@ -37,7 +37,7 @@ public function compile(\Twig_Compiler $compiler)
// the variables in the third argument
$label = $arguments[1];
$variables = isset($arguments[2]) ? $arguments[2] : null;
$lineno = $label->getLine();
$lineno = $label->getTemplateLine();

if ($label instanceof \Twig_Node_Expression_Constant) {
// If the label argument is given as a constant, we can either
Expand Down
6 changes: 3 additions & 3 deletions src/Symfony/Bridge/Twig/Node/TransNode.php
Expand Up @@ -109,18 +109,18 @@ protected function compileString(\Twig_Node $body, \Twig_Node_Expression_Array $
preg_match_all('/(?<!%)%([^%]+)%/', $msg, $matches);

foreach ($matches[1] as $var) {
$key = new \Twig_Node_Expression_Constant('%'.$var.'%', $body->getLine());
$key = new \Twig_Node_Expression_Constant('%'.$var.'%', $body->getTemplateLine());
if (!$vars->hasElement($key)) {
if ('count' === $var && $this->hasNode('count')) {
$vars->addElement($this->getNode('count'), $key);
} else {
$varExpr = new \Twig_Node_Expression_Name($var, $body->getLine());
$varExpr = new \Twig_Node_Expression_Name($var, $body->getTemplateLine());
$varExpr->setAttribute('ignore_strict_check', $ignoreStrictCheck);
$vars->addElement($varExpr, $key);
}
}
}

return array(new \Twig_Node_Expression_Constant(str_replace('%%', '%', trim($msg)), $body->getLine()), $vars);
return array(new \Twig_Node_Expression_Constant(str_replace('%%', '%', trim($msg)), $body->getTemplateLine()), $vars);
}
}
Expand Up @@ -50,10 +50,10 @@ protected function doEnterNode(\Twig_Node $node, \Twig_Environment $env)
return $node;
} else {
$var = $env->getParser()->getVarName();
$name = new \Twig_Node_Expression_AssignName($var, $node->getLine());
$this->scope->set('domain', new \Twig_Node_Expression_Name($var, $node->getLine()));
$name = new \Twig_Node_Expression_AssignName($var, $node->getTemplateLine());
$this->scope->set('domain', new \Twig_Node_Expression_Name($var, $node->getTemplateLine()));

return new \Twig_Node_Set(false, new \Twig_Node(array($name)), new \Twig_Node(array($node->getNode('expr'))), $node->getLine());
return new \Twig_Node_Set(false, new \Twig_Node(array($name)), new \Twig_Node(array($node->getNode('expr'))), $node->getTemplateLine());
}
}

Expand All @@ -71,7 +71,7 @@ protected function doEnterNode(\Twig_Node $node, \Twig_Environment $env)
} else {
if (!$arguments->hasNode($ind)) {
if (!$arguments->hasNode($ind - 1)) {
$arguments->setNode($ind - 1, new \Twig_Node_Expression_Array(array(), $node->getLine()));
$arguments->setNode($ind - 1, new \Twig_Node_Expression_Array(array(), $node->getTemplateLine()));
}

$arguments->setNode($ind, $this->scope->get('domain'));
Expand Down
Expand Up @@ -64,7 +64,7 @@ public function parse(\Twig_Token $token)
$body = $this->parser->subparse(array($this, 'decideTransChoiceFork'), true);

if (!$body instanceof \Twig_Node_Text && !$body instanceof \Twig_Node_Expression) {
throw new \Twig_Error_Syntax('A message inside a transchoice tag must be a simple text.', $body->getLine(), $stream->getSourceContext()->getName());
throw new \Twig_Error_Syntax('A message inside a transchoice tag must be a simple text.', $body->getTemplateLine(), $stream->getSourceContext()->getName());
}

$stream->expect(\Twig_Token::BLOCK_END_TYPE);
Expand Down
2 changes: 1 addition & 1 deletion src/Symfony/Bridge/Twig/TokenParser/TransTokenParser.php
Expand Up @@ -64,7 +64,7 @@ public function parse(\Twig_Token $token)
$body = $this->parser->subparse(array($this, 'decideTransFork'), true);

if (!$body instanceof \Twig_Node_Text && !$body instanceof \Twig_Node_Expression) {
throw new \Twig_Error_Syntax('A message inside a trans tag must be a simple text.', $body->getLine(), $stream->getSourceContext()->getName());
throw new \Twig_Error_Syntax('A message inside a trans tag must be a simple text.', $body->getTemplateLine(), $stream->getSourceContext()->getName());
}

$stream->expect(\Twig_Token::BLOCK_END_TYPE);
Expand Down

0 comments on commit 8974d77

Please sign in to comment.