blob: 59e836dbdcc79c71d513436de6ad49b3351e499a [file] [log] [blame]
Matthias Andreas Benkard12a57352021-12-28 18:02:04 +01001<?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
12namespace Twig\NodeVisitor;
13
14use Twig\Environment;
15use Twig\Node\Node;
16
17/**
18 * Interface for node visitor classes.
19 *
20 * @author Fabien Potencier <fabien@symfony.com>
21 */
22interface NodeVisitorInterface
23{
24 /**
25 * Called before child nodes are visited.
26 *
27 * @return Node The modified node
28 */
29 public function enterNode(Node $node, Environment $env): Node;
30
31 /**
32 * Called after child nodes are visited.
33 *
34 * @return Node|null The modified node or null if the node must be removed
35 */
36 public function leaveNode(Node $node, Environment $env): ?Node;
37
38 /**
39 * Returns the priority for this visitor.
40 *
41 * Priority should be between -10 and 10 (0 is the default).
42 *
43 * @return int The priority level
44 */
45 public function getPriority();
46}