private function traitDeclaration() {
    $node = new TraitNode();
    $this->matchDocComment($node);
    $this->mustMatch(T_TRAIT, $node);
    $name_node = new NameNode();
    $this->mustMatch(T_STRING, $name_node, NULL, TRUE);
    $node->addChild($name_node, 'name');
    if ($this->currentType === T_EXTENDS) {
      throw new ParserException(
        $this->filename,
        $this->iterator->getLineNumber(),
        $this->iterator->getColumnNumber(),
        'Traits can only be composed from other traits with the \'use\' keyword.'
      );
    }
    if ($this->currentType === T_IMPLEMENTS) {
      throw new ParserException(
        $this->filename,
        $this->iterator->getLineNumber(),
        $this->iterator->getColumnNumber(),
        'Traits can not implement interfaces.'
      );
    }
    $this->matchHidden($node);
    $statement_block = new StatementBlockNode();
    $this->mustMatch('{', $statement_block, NULL, FALSE, TRUE);
    while ($this->currentType !== NULL && $this->currentType !== '}') {
      $this->matchHidden($statement_block);
      $statement_block->addChild($this->classStatement(TRUE));
    }
    $this->mustMatch('}', $statement_block, NULL, TRUE, TRUE);
    $node->addChild($statement_block, 'statements');
    return $node;
  }
private function traitDeclaration() {
    $node = new TraitNode();
    $this->matchDocComment($node);
    $this->mustMatch(T_TRAIT, $node);
    $name_node = new NameNode();
    $this->mustMatch(T_STRING, $name_node, NULL, TRUE);
    $node->addChild($name_node, 'name');
    if ($this->currentType === T_EXTENDS) {
      throw new ParserException(
        $this->filename,
        $this->iterator->getLineNumber(),
        $this->iterator->getColumnNumber(),
        'Traits can only be composed from other traits with the \'use\' keyword.'
      );
    }
    if ($this->currentType === T_IMPLEMENTS) {
      throw new ParserException(
        $this->filename,
        $this->iterator->getLineNumber(),
        $this->iterator->getColumnNumber(),
        'Traits can not implement interfaces.'
      );
    }
    $this->matchHidden($node);
    $statement_block = new StatementBlockNode();
    $this->mustMatch('{', $statement_block, NULL, FALSE, TRUE);
    while ($this->currentType !== NULL && $this->currentType !== '}') {
      $this->matchHidden($statement_block);
      $statement_block->addChild($this->classStatement(TRUE));
    }
    $this->mustMatch('}', $statement_block, NULL, TRUE, TRUE);
    $node->addChild($statement_block, 'statements');
    return $node;
  }
private function traitDeclaration ( ) { $ node = new TraitNode ( ) ; $ this -> matchDocComment ( $ node ) ; $ this -> mustMatch ( T_TRAIT , $ node ) ; $ name_node = new NameNode ( ) ; $ this -> mustMatch ( T_STRING , $ name_node , NULL , TRUE ) ; $ node -> addChild ( $ name_node , 'name' ) ; if ( $ this -> currentType === T_EXTENDS ) { throw new ParserException ( $ this -> filename , $ this -> iterator -> getLineNumber ( ) , $ this -> iterator -> getColumnNumber ( ) , 'Traits can only be composed from other traits with the \'use\' keyword.' ) ; } if ( $ this -> currentType === T_IMPLEMENTS ) { throw new ParserException ( $ this -> filename , $ this -> iterator -> getLineNumber ( ) , $ this -> iterator -> getColumnNumber ( ) , 'Traits can not implement interfaces.' ) ; } $ this -> matchHidden ( $ node ) ; $ statement_block = new StatementBlockNode ( ) ; $ this -> mustMatch ( '{' , $ statement_block , NULL , FALSE , TRUE ) ; while ( $ this -> currentType !== NULL && $ this -> currentType !== '}' ) { $ this -> matchHidden ( $ statement_block ) ; $ statement_block -> addChild ( $ this -> classStatement ( TRUE ) ) ; } $ this -> mustMatch ( '}' , $ statement_block , NULL , TRUE , TRUE ) ; $ node -> addChild ( $ statement_block , 'statements' ) ; return $ node ; }
Parse a trait declaration.
@return TraitNode
@throws ParserException
Parse a trait declaration .