"Fossies" - the Fresh Open Source Software Archive

Member "grav/vendor/twig/twig/src/NodeVisitor/AbstractNodeVisitor.php" (19 Mar 2020, 1585 Bytes) of package /linux/www/grav-v1.6.23.zip:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) PHP source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "AbstractNodeVisitor.php" see the Fossies "Dox" file reference documentation.

    1 <?php
    2 
    3 /*
    4  * This file is part of Twig.
    5  *
    6  * (c) Fabien Potencier
    7  *
    8  * For the full copyright and license information, please view the LICENSE
    9  * file that was distributed with this source code.
   10  */
   11 
   12 namespace Twig\NodeVisitor;
   13 
   14 use Twig\Environment;
   15 use Twig\Node\Node;
   16 
   17 /**
   18  * Used to make node visitors compatible with Twig 1.x and 2.x.
   19  *
   20  * To be removed in Twig 3.1.
   21  *
   22  * @author Fabien Potencier <fabien@symfony.com>
   23  */
   24 abstract class AbstractNodeVisitor implements NodeVisitorInterface
   25 {
   26     final public function enterNode(\Twig_NodeInterface $node, Environment $env)
   27     {
   28         if (!$node instanceof Node) {
   29             throw new \LogicException(sprintf('%s only supports \Twig\Node\Node instances.', __CLASS__));
   30         }
   31 
   32         return $this->doEnterNode($node, $env);
   33     }
   34 
   35     final public function leaveNode(\Twig_NodeInterface $node, Environment $env)
   36     {
   37         if (!$node instanceof Node) {
   38             throw new \LogicException(sprintf('%s only supports \Twig\Node\Node instances.', __CLASS__));
   39         }
   40 
   41         return $this->doLeaveNode($node, $env);
   42     }
   43 
   44     /**
   45      * Called before child nodes are visited.
   46      *
   47      * @return Node The modified node
   48      */
   49     abstract protected function doEnterNode(Node $node, Environment $env);
   50 
   51     /**
   52      * Called after child nodes are visited.
   53      *
   54      * @return Node|false|null The modified node or null if the node must be removed
   55      */
   56     abstract protected function doLeaveNode(Node $node, Environment $env);
   57 }
   58 
   59 class_alias('Twig\NodeVisitor\AbstractNodeVisitor', 'Twig_BaseNodeVisitor');