示例#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;
 }
示例#2
0
 /**
  * Parses the given token reader
  *
  * @param \vc\Tokens\Access $access The token access
  * @return \vc\Data\Constant Returns the created constant
  */
 public function parseConstant(\vc\Tokens\Access $access)
 {
     $access->findRequired(array(Token::T_CONST));
     $name = $access->findRequired(array(Token::T_STRING));
     $const = new \vc\Data\Constant($name->getContent());
     $access->findRequired(array(Token::T_EQUALS));
     $const->setValue($this->value->parseValue($access));
     $access->findRequired(array(Token::T_SEMICOLON));
     return $const;
 }
示例#3
0
文件: Args.php 项目: Nycto/phpVocab
 /**
  * Parses a single argument and returns the data that is created
  *
  * @param \vc\Tokens\Access $access
  * @return \vc\Data\Arg
  */
 private function parseArg(\vc\Tokens\Access $access)
 {
     $arg = new \vc\Data\Arg();
     // We've already ensured this token is an appropriate type in the
     // calling method, so we don't need to do any extensive checking
     $token = $access->peekAtToken();
     // Parse out any type hinting
     if ($token->is(array(Token::T_ARRAY, Token::T_STRING, Token::T_NS_SEPARATOR))) {
         $arg->setType($token->is(Token::T_ARRAY) ? 'array' : $this->path->parsePath($access));
         $access->popToken();
         $token = $access->peekToRequired(array(Token::T_AMPERSAND, Token::T_VARIABLE));
     }
     // Check to see if this argument is being passed by reference
     if ($token->is(Token::T_AMPERSAND)) {
         $arg->setReference(TRUE);
         $access->popToken();
         $token = $access->peekToRequired(array(Token::T_VARIABLE));
     }
     // Grab the name of the argument. Up to this point, it has only been
     // peeked at, so we need to remove it from the list
     $arg->setVariable($token->getContent());
     $access->popToken();
     // Look for a default value for this argument
     $token = $access->find(array(Token::T_EQUALS));
     if ($token && $token->is(Token::T_EQUALS)) {
         $arg->setDefault($this->value->parseValue($access));
     }
     // Pop the comma off the list if one exists
     $access->find(array(Token::T_COMMA));
     return $arg;
 }