private function _foreach() {
    $node = new ForeachNode();
    $this->mustMatch(T_FOREACH, $node);
    $this->mustMatch('(', $node, 'openParen');
    $node->addChild($this->expr(), 'onEach');
    $this->mustMatch(T_AS, $node);
    $value = $this->foreachVariable();
    if ($this->currentType === T_DOUBLE_ARROW) {
      $node->addChild($value, 'key');
      $this->mustMatch(T_DOUBLE_ARROW, $node);
      $node->addChild($this->foreachVariable(), 'value');
    }
    else {
      $node->addChild($value, 'value');
    }
    $this->mustMatch(')', $node, 'closeParen', FALSE, TRUE);
    if ($this->tryMatch(':', $node, NULL, FALSE, TRUE)) {
      $node->addChild($this->innerStatementListNode(T_ENDFOREACH), 'body');
      $this->mustMatch(T_ENDFOREACH, $node);
      $this->endStatement($node);
      return $node;
    }
    else {
      $node->addChild($this->statement(), 'body');
      return $node;
    }
  }
private function _foreach() {
    $node = new ForeachNode();
    $this->mustMatch(T_FOREACH, $node);
    $this->mustMatch('(', $node, 'openParen');
    $node->addChild($this->expr(), 'onEach');
    $this->mustMatch(T_AS, $node);
    $value = $this->foreachVariable();
    if ($this->currentType === T_DOUBLE_ARROW) {
      $node->addChild($value, 'key');
      $this->mustMatch(T_DOUBLE_ARROW, $node);
      $node->addChild($this->foreachVariable(), 'value');
    }
    else {
      $node->addChild($value, 'value');
    }
    $this->mustMatch(')', $node, 'closeParen', FALSE, TRUE);
    if ($this->tryMatch(':', $node, NULL, FALSE, TRUE)) {
      $node->addChild($this->innerStatementListNode(T_ENDFOREACH), 'body');
      $this->mustMatch(T_ENDFOREACH, $node);
      $this->endStatement($node);
      return $node;
    }
    else {
      $node->addChild($this->statement(), 'body');
      return $node;
    }
  }
private function _foreach ( ) { $ node = new ForeachNode ( ) ; $ this -> mustMatch ( T_FOREACH , $ node ) ; $ this -> mustMatch ( '(' , $ node , 'openParen' ) ; $ node -> addChild ( $ this -> expr ( ) , 'onEach' ) ; $ this -> mustMatch ( T_AS , $ node ) ; $ value = $ this -> foreachVariable ( ) ; if ( $ this -> currentType === T_DOUBLE_ARROW ) { $ node -> addChild ( $ value , 'key' ) ; $ this -> mustMatch ( T_DOUBLE_ARROW , $ node ) ; $ node -> addChild ( $ this -> foreachVariable ( ) , 'value' ) ; } else { $ node -> addChild ( $ value , 'value' ) ; } $ this -> mustMatch ( ')' , $ node , 'closeParen' , FALSE , TRUE ) ; if ( $ this -> tryMatch ( ':' , $ node , NULL , FALSE , TRUE ) ) { $ node -> addChild ( $ this -> innerStatementListNode ( T_ENDFOREACH ) , 'body' ) ; $ this -> mustMatch ( T_ENDFOREACH , $ node ) ; $ this -> endStatement ( $ node ) ; return $ node ; } else { $ node -> addChild ( $ this -> statement ( ) , 'body' ) ; return $ node ; } }
Parse foreach control structure.
@return ForeachNode
Parse foreach control structure .