Exemplo n.º 1
0
 /**
  * Visits a code element containing an array fetch operator type.
  *
  * @param ezcTemplateArrayFetchOperatorAstNode $operator The code element containing the array fetch operator.
  * @return void
  */
 public function visitArrayFetchOperatorAstNode(ezcTemplateArrayFetchOperatorAstNode $operator)
 {
     $parameters = $operator->getParameters();
     $count = count($parameters);
     if ($count < $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);
     for ($i = 1; $i < $count; ++$i) {
         // Generate the operator symbol before parameter.
         $this->write("[");
         // Generate code for operand
         $parameters[$i]->accept($this);
         // and after parameter.
         $this->write("]");
     }
 }