vendor/twig/twig/src/NodeVisitor/AbstractNodeVisitor.php line 28

Open in your IDE?
  1. <?php
  2. /*
  3. * This file is part of Twig.
  4. *
  5. * (c) Fabien Potencier
  6. *
  7. * For the full copyright and license information, please view the LICENSE
  8. * file that was distributed with this source code.
  9. */
  10. namespace Twig\NodeVisitor;
  11. use Twig\Environment;
  12. use Twig\Node\Node;
  13. /**
  14. * Used to make node visitors compatible with Twig 1.x and 2.x.
  15. *
  16. * @author Fabien Potencier <fabien@symfony.com>
  17. *
  18. * @deprecated since Twig 3.9 (to be removed in 4.0)
  19. */
  20. abstract class AbstractNodeVisitor implements NodeVisitorInterface
  21. {
  22. final public function enterNode(Node $node, Environment $env): Node
  23. {
  24. return $this->doEnterNode($node, $env);
  25. }
  26. final public function leaveNode(Node $node, Environment $env): ?Node
  27. {
  28. return $this->doLeaveNode($node, $env);
  29. }
  30. /**
  31. * Called before child nodes are visited.
  32. *
  33. * @return Node The modified node
  34. */
  35. abstract protected function doEnterNode(Node $node, Environment $env);
  36. /**
  37. * Called after child nodes are visited.
  38. *
  39. * @return Node|null The modified node or null if the node must be removed
  40. */
  41. abstract protected function doLeaveNode(Node $node, Environment $env);
  42. }