Binary.php 919 B

123456789101112131415161718192021222324252627282930313233343536
  1. <?php
  2. /*
  3. * This file is part of Twig.
  4. *
  5. * (c) 2009 Fabien Potencier
  6. * (c) 2009 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. abstract class Twig_Node_Expression_Binary extends Twig_Node_Expression
  12. {
  13. public function __construct(Twig_NodeInterface $left, Twig_NodeInterface $right, $lineno)
  14. {
  15. parent::__construct(array('left' => $left, 'right' => $right), array(), $lineno);
  16. }
  17. public function compile(Twig_Compiler $compiler)
  18. {
  19. $compiler
  20. ->raw('(')
  21. ->subcompile($this->getNode('left'))
  22. ->raw(' ')
  23. ;
  24. $this->operator($compiler);
  25. $compiler
  26. ->raw(' ')
  27. ->subcompile($this->getNode('right'))
  28. ->raw(')')
  29. ;
  30. }
  31. abstract public function operator(Twig_Compiler $compiler);
  32. }