/**
  * Parses static variables.
  *
  * @param \TokenReflection\Stream\StreamBase $tokenStream Token substream
  *
  * @return \TokenReflection\ReflectionFunctionBase
  * @throws \TokenReflection\Exception\ParseException If static variables could not be parsed.
  */
 protected final function parseStaticVariables(Stream $tokenStream)
 {
     $type = $tokenStream->getType();
     if ('{' === $type) {
         if ($this->getBroker()->isOptionSet(Broker::OPTION_PARSE_FUNCTION_BODY)) {
             $tokenStream->skipWhitespaces(true);
             while ('}' !== ($type = $tokenStream->getType())) {
                 switch ($type) {
                     case T_STATIC:
                         $type = $tokenStream->skipWhitespaces(true)->getType();
                         if (T_VARIABLE !== $type) {
                             // Late static binding
                             break;
                         }
                         while (T_VARIABLE === $type) {
                             $variableName = $tokenStream->getTokenValue();
                             $variableDefinition = array();
                             $type = $tokenStream->skipWhitespaces(true)->getType();
                             if ('=' === $type) {
                                 $type = $tokenStream->skipWhitespaces(true)->getType();
                                 $level = 0;
                                 while ($tokenStream->valid()) {
                                     switch ($type) {
                                         case '(':
                                         case '[':
                                         case '{':
                                         case T_CURLY_OPEN:
                                         case T_DOLLAR_OPEN_CURLY_BRACES:
                                             $level++;
                                             break;
                                         case ')':
                                         case ']':
                                         case '}':
                                             $level--;
                                             break;
                                         case ';':
                                         case ',':
                                             if (0 === $level) {
                                                 break 2;
                                             }
                                         default:
                                             break;
                                     }
                                     $variableDefinition[] = $tokenStream->current();
                                     $type = $tokenStream->skipWhitespaces(true)->getType();
                                 }
                                 if (!$tokenStream->valid()) {
                                     throw new Exception\ParseException($this, $tokenStream, 'Invalid end of token stream.', Exception\ParseException::READ_BEYOND_EOS);
                                 }
                             }
                             $this->staticVariablesDefinition[substr($variableName, 1)] = $variableDefinition;
                             if (',' === $type) {
                                 $type = $tokenStream->skipWhitespaces(true)->getType();
                             } else {
                                 break;
                             }
                         }
                         break;
                     case T_FUNCTION:
                         // Anonymous function -> skip to its end
                         if (!$tokenStream->find('{')) {
                             throw new Exception\ParseException($this, $tokenStream, 'Could not find beginning of the anonymous function.', Exception\ParseException::UNEXPECTED_TOKEN);
                         }
                         // Break missing intentionally
                     // Break missing intentionally
                     case '{':
                     case '[':
                     case '(':
                     case T_CURLY_OPEN:
                     case T_DOLLAR_OPEN_CURLY_BRACES:
                         $tokenStream->findMatchingBracket()->skipWhitespaces(true);
                         break;
                     default:
                         $tokenStream->skipWhitespaces();
                         break;
                 }
             }
         } else {
             $tokenStream->findMatchingBracket();
         }
     } elseif (';' !== $type) {
         throw new Exception\ParseException($this, $tokenStream, 'Unexpected token found.', Exception\ParseException::UNEXPECTED_TOKEN);
     }
     return $this;
 }