vendor/twig/twig/src/Node/PrintNode.php line 38

Open in your IDE?
  1. <?php
  2. /*
  3.  * This file is part of Twig.
  4.  *
  5.  * (c) Fabien Potencier
  6.  * (c) Armin Ronacher
  7.  *
  8.  * For the full copyright and license information, please view the LICENSE
  9.  * file that was distributed with this source code.
  10.  */
  11. namespace Twig\Node;
  12. use Twig\Attribute\YieldReady;
  13. use Twig\Compiler;
  14. use Twig\Node\Expression\AbstractExpression;
  15. /**
  16.  * Represents a node that outputs an expression.
  17.  *
  18.  * @author Fabien Potencier <fabien@symfony.com>
  19.  */
  20. #[YieldReady]
  21. class PrintNode extends Node implements NodeOutputInterface
  22. {
  23.     public function __construct(AbstractExpression $exprint $lineno, ?string $tag null)
  24.     {
  25.         parent::__construct(['expr' => $expr], [], $lineno$tag);
  26.     }
  27.     public function compile(Compiler $compiler): void
  28.     {
  29.         $compiler->addDebugInfo($this);
  30.         $compiler
  31.             ->write('yield ')
  32.             ->subcompile($this->getNode('expr'))
  33.             ->raw(";\n")
  34.         ;
  35.     }
  36. }