Skip to content

Commit

Permalink
bug #23073 [TwigBridge] Fix namespaced classes (ogizanagi)
Browse files Browse the repository at this point in the history
This PR was merged into the 2.7 branch.

Discussion
----------

[TwigBridge] Fix namespaced classes

| Q             | A
| ------------- | ---
| Branch?       | 2.7 <!-- see comment below -->
| Bug fix?      | yes
| New feature?  | no <!-- don't forget updating src/**/CHANGELOG.md files -->
| BC breaks?    | no
| Deprecations? | no <!-- don't forget updating UPGRADE-*.md files -->
| Tests pass?   | yes
| Fixed tickets | #23072 <!-- #-prefixed issue number(s), if any -->
| License       | MIT
| Doc PR        | N/A

Commits
-------

a1cdc2d [TwigBridge] Fix namespaced classes
  • Loading branch information
fabpot committed Jun 6, 2017
2 parents 621b769 + a1cdc2d commit 658236b
Showing 1 changed file with 5 additions and 3 deletions.
Expand Up @@ -14,13 +14,15 @@
use Symfony\Bridge\Twig\Node\TransNode;
use Symfony\Bridge\Twig\Node\TransDefaultDomainNode;
use Twig\Environment;
use Twig\Node\BlockNode;
use Twig\Node\Expression\ArrayExpression;
use Twig\Node\Expression\AssignNameExpression;
use Twig\Node\Expression\ConstantExpression;
use Twig\Node\Expression\FilterExpression;
use Twig\Node\Expression\NameExpression;
use Twig\Node\ModuleNode;
use Twig\Node\Node;
use Twig\Node\SetNode;
use Twig\NodeVisitor\AbstractNodeVisitor;

/**
Expand Down Expand Up @@ -48,7 +50,7 @@ public function __construct()
*/
protected function doEnterNode(Node $node, Environment $env)
{
if ($node instanceof Node_Block || $node instanceof ModuleNode) {
if ($node instanceof BlockNode || $node instanceof ModuleNode) {
$this->scope = $this->scope->enter();
}

Expand All @@ -62,7 +64,7 @@ protected function doEnterNode(Node $node, Environment $env)
$name = new AssignNameExpression($var, $node->getTemplateLine());
$this->scope->set('domain', new NameExpression($var, $node->getTemplateLine()));

return new Node_Set(false, new Node(array($name)), new Node(array($node->getNode('expr'))), $node->getTemplateLine());
return new SetNode(false, new Node(array($name)), new Node(array($node->getNode('expr'))), $node->getTemplateLine());
}
}

Expand Down Expand Up @@ -104,7 +106,7 @@ protected function doLeaveNode(Node $node, Environment $env)
return false;
}

if ($node instanceof Node_Block || $node instanceof ModuleNode) {
if ($node instanceof BlockNode || $node instanceof ModuleNode) {
$this->scope = $this->scope->leave();
}

Expand Down

0 comments on commit 658236b

Please sign in to comment.