composer package updates
[openemr.git] / vendor / twig / twig / lib / Twig / BaseNodeVisitor.php
blobd8ef02fb281cb314e3930bbf0f185d184e1458ad
1 <?php
3 /*
4 * This file is part of Twig.
6 * (c) Fabien Potencier
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
12 /**
13 * Twig_BaseNodeVisitor can be used to make node visitors compatible with Twig 1.x and 2.x.
15 * @author Fabien Potencier <fabien@symfony.com>
17 abstract class Twig_BaseNodeVisitor implements Twig_NodeVisitorInterface
19 final public function enterNode(Twig_NodeInterface $node, Twig_Environment $env)
21 if (!$node instanceof Twig_Node) {
22 throw new LogicException('Twig_BaseNodeVisitor only supports Twig_Node instances.');
25 return $this->doEnterNode($node, $env);
28 final public function leaveNode(Twig_NodeInterface $node, Twig_Environment $env)
30 if (!$node instanceof Twig_Node) {
31 throw new LogicException('Twig_BaseNodeVisitor only supports Twig_Node instances.');
34 return $this->doLeaveNode($node, $env);
37 /**
38 * Called before child nodes are visited.
40 * @return Twig_Node The modified node
42 abstract protected function doEnterNode(Twig_Node $node, Twig_Environment $env);
44 /**
45 * Called after child nodes are visited.
47 * @return Twig_Node|false The modified node or false if the node must be removed
49 abstract protected function doLeaveNode(Twig_Node $node, Twig_Environment $env);
52 class_alias('Twig_BaseNodeVisitor', 'Twig\NodeVisitor\AbstractNodeVisitor', false);
53 class_exists('Twig_Environment');
54 class_exists('Twig_Node');