Esempio n. 1
0
 /**
  * @param int $token
  * @param string $value
  *
  * @return bool if true is returned, lexer will end its loop
  * @throws LexerException
  */
 protected function token($token, $value)
 {
     switch ($token) {
         case T_STRING:
             $this->constant->name = $value;
             foreach ($this->reflectionTokenizer->getTokenStack() as $stackToken) {
                 list($innerToken, $innerValue) = $stackToken;
                 switch ($innerToken) {
                     case T_DOC_COMMENT:
                         $this->constant->annotation = $innerValue;
                         break;
                 }
             }
             break;
         case '=':
             $this->constant->value = ValueLexer::build($this->reflectionTokenizer->setContinue());
             break;
         case ',':
             $this->reflectionTokenizer->getTokenStack()->cleanup();
             $this->source[$this->constant->name] = $this->constant;
             $this->constant = $this->createConstant();
             break;
         case ';':
             $this->reflectionTokenizer->getTokenStack()->cleanup();
             $this->reflectionTokenizer->setSkipNext();
             $this->source[$this->constant->name] = $this->constant;
             return true;
     }
     return false;
 }
Esempio n. 2
0
 /**
  * @param int $token
  * @param string $value
  *
  * @return bool if true is returned, lexer will end its loop
  * @throws LexerException
  */
 protected function token($token, $value)
 {
     switch ($token) {
         case T_VARIABLE:
             $this->property->name = ltrim($value, '$');
             foreach ($this->reflectionTokenizer->getTokenStack() as $stackToken) {
                 list($innerToken, $innerValue) = $stackToken;
                 switch ($innerToken) {
                     case T_DOC_COMMENT:
                         $this->property->annotation = $innerValue;
                         break;
                     case T_STATIC:
                         $this->static = $this->property->static = true;
                         break;
                     case T_PUBLIC:
                         $this->visibility = $this->property->visibility = 'public';
                         break;
                     case T_PROTECTED:
                         $this->visibility = $this->property->visibility = 'protected';
                         break;
                     case T_PRIVATE:
                         $this->visibility = $this->property->visibility = 'private';
                         break;
                 }
             }
             break;
         case '=':
             $this->property->value = ValueLexer::build($this->reflectionTokenizer->setContinue());
             break;
         case ',':
             $this->reflectionTokenizer->getTokenStack()->cleanup();
             $this->source[$this->property->name] = $this->property;
             $this->property = $this->createProperty();
             break;
         case ';':
             $this->reflectionTokenizer->getTokenStack()->cleanup();
             $this->reflectionTokenizer->setSkipNext();
             $this->source[$this->property->name] = $this->property;
             return true;
     }
     return false;
 }
Esempio n. 3
0
 /**
  * @param int $token
  * @param string $value
  *
  * @return bool if true is returned, lexer will end its loop
  * @throws LexerException
  */
 protected function token($token, $value)
 {
     switch ($token) {
         case T_NS_SEPARATOR:
             $this->parameter->hint .= $value;
             break;
         case T_ELLIPSIS:
             $this->parameter->variadic = true;
             break;
         case T_ARRAY:
         case T_STRING:
         case T_CALLABLE:
             $this->parameter->hint .= $value;
             break;
         case '&':
             $this->parameter->reference = true;
             break;
         case T_VARIABLE:
             $this->parameter->name = ltrim($value, '$');
             break;
         case '=':
             $this->parameter->default = ValueLexer::build($this->reflectionTokenizer->setContinue());
             $this->parameter->optional = true;
             break;
         case ',':
             $this->source[$this->parameter->name] = $this->parameter;
             $this->parameter = $this->createParameter();
             break;
         case ')':
             if ($this->parameter->name) {
                 $this->source[$this->parameter->name] = $this->parameter;
             }
             $this->reflectionTokenizer->setSkipNext();
             return true;
     }
     return false;
 }