Exemple #1
0
 /**
  * visitBinaryOperatorAstNode
  *
  * @param ezcTemplateOperatorAstNode  $operator
  * @return void
  */
 public function visitBinaryOperatorAstNode(ezcTemplateOperatorAstNode $operator)
 {
     $parameters = $operator->getParameters();
     if (count($parameters) < $operator->minParameterCount) {
         throw new ezcTemplateInternalException("The operator <" . get_class($operator) . " contains only " . count($parameters) . " parameters but should at least have {$operator->minParameterCount} parameters.");
     }
     array_unshift($this->nodePath, $operator);
     $this->acceptAndUpdate($operator->parameters[0]);
     $this->acceptAndUpdate($operator->parameters[1]);
     array_shift($this->nodePath);
 }
 /**
  * Visits a code element containing a binary operator type.
  * Binary operators take two parameters and consist of a symbol.
  *
  * @param ezcTemplateOperatorAstNode $operator The code element containing the operator with parameters.
  * @return void
  */
 public function visitBinaryOperatorAstNode(ezcTemplateOperatorAstNode $operator)
 {
     $parameters = $operator->getParameters();
     if (count($parameters) < $operator->minParameterCount) {
         throw new ezcTemplateInternalException("The operator <" . get_class($operator) . " contains only " . count($parameters) . " parameters but should at least have {$operator->minParameterCount} parameters.");
     }
     // Generate code for first operand
     $parameters[0]->accept($this);
     // Generate the operator symbol in between parameters.
     if ($operator instanceof ezcTemplateReferenceOperatorAstNode) {
         // No spaces around the '->'.  PHP cannot handle: $myObj -> class
         $this->write($operator->getOperatorPHPSymbol());
     } else {
         $this->write(" " . $operator->getOperatorPHPSymbol() . " ");
     }
     // Generate code for second operand
     $parameters[1]->accept($this);
 }