Esempio n. 1
0
 /**
  * Parses the given token reader
  *
  * @param \vc\Data\Signature $signature The signature to use as a source
  * @param \vc\Tokens\Access $access The token access
  * @return \vc\Data\Property
  */
 public function parseProperty(\vc\Data\Signature $signature, \vc\Tokens\Access $access)
 {
     $prop = $signature->buildProperty();
     // Keep looking for modifier tokens until we reach the variable.
     // This isn't as strict as it could be about token order, but it greatly
     // simplifies the method to do it like this.
     do {
         $token = $access->findRequired(array(Token::T_STATIC, Token::T_VAR, Token::T_VARIABLE, Token::T_PUBLIC, Token::T_PROTECTED, Token::T_PRIVATE));
         if ($token->is(array(Token::T_PUBLIC, Token::T_PROTECTED, Token::T_PRIVATE))) {
             $prop->setVisibility(\vc\Data\Visibility::fromToken($token));
         } else {
             if ($token->is(Token::T_STATIC)) {
                 $prop->setStatic(TRUE);
             }
         }
     } while (!$token->is(Token::T_VARIABLE));
     $prop->setName($token->getContent());
     $token = $access->findRequired(array(Token::T_SEMICOLON, Token::T_EQUALS));
     // Look for any default value
     if ($token->is(Token::T_EQUALS)) {
         $prop->setValue($this->value->parseValue($access));
         $access->findRequired(array(Token::T_SEMICOLON));
     }
     return $prop;
 }
Esempio n. 2
0
 /**
  * Parses the given token reader
  *
  * @param \vc\Data\Signature $signature The base data from which to build
  *      the method
  * @param \vc\Tokens\Access $access The token stream
  * @return \vc\Data\Routine\Method
  */
 public function parseMethod(\vc\Data\Signature $signature, \vc\Tokens\Access $access)
 {
     $method = $signature->buildMethod();
     // Continue iterating until we encounter a Function token
     while (TRUE) {
         $token = $access->peekToRequired(array(Token::T_STATIC, Token::T_ABSTRACT, Token::T_FINAL, Token::T_PUBLIC, Token::T_PROTECTED, Token::T_PRIVATE, Token::T_FUNCTION));
         // We don't want to consume the function token because the routine
         // parser looks for it. Break before we get a chance to pop it off
         // the stream
         if ($token->is(Token::T_FUNCTION)) {
             break;
         }
         $access->popToken();
         if ($token->is(array(Token::T_PUBLIC, Token::T_PROTECTED, Token::T_PRIVATE))) {
             $method->setVisibility(\vc\Data\Visibility::fromToken($token));
         } else {
             if ($token->is(Token::T_STATIC)) {
                 $method->setStatic(TRUE);
             } else {
                 if ($token->is(Token::T_ABSTRACT)) {
                     $method->setAbstract(TRUE);
                 } else {
                     if ($token->is(Token::T_FINAL)) {
                         $method->setFinal(TRUE);
                     }
                 }
             }
         }
     }
     $this->routine->parseRoutine($method, $access);
     return $method;
 }