Binary.php 1.0KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  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. /**
  18. * Compiles the node to PHP.
  19. *
  20. * @param Twig_Compiler A Twig_Compiler instance
  21. */
  22. public function compile(Twig_Compiler $compiler)
  23. {
  24. $compiler
  25. ->raw('(')
  26. ->subcompile($this->getNode('left'))
  27. ->raw(' ')
  28. ;
  29. $this->operator($compiler);
  30. $compiler
  31. ->raw(' ')
  32. ->subcompile($this->getNode('right'))
  33. ->raw(')')
  34. ;
  35. }
  36. abstract public function operator(Twig_Compiler $compiler);
  37. }