Handles a <variable>-token and parses it into a variable assignment.

@param array $token the <variable>-token

@throws Exception
496334
protected function handleVariable(array $token)
    {

        $node = $this->createNode('variable');
        $node->name = $token['name'];
        $node->attributes = [];
        $this->current = $node;
    }
368606
private function _processSemiColon($token) {
		// ";" should never be preceded by a whitespace
		$this->_checkNoWhiteSpaceBefore($token->text);

		// ";" should never be preceded by ;
		$this->_checkEmptyStatement();

		// If we are in a statement not surrounded by curly braces, we unstack the last line.
		if ($this->statementStack->getCurrentStackItem()->noCurly === true) {
			$this->statementStack->pop();
		}
	}
949746
public function parse(Token $token): FunctionCallValue
    {
        if (null === $this->parser) {
            throw ExpressionLanguageExceptionFactory::createForExpectedMethodCallOnlyIfHasAParser(__METHOD__);
        }

        if (1 !== preg_match(self::REGEX, $token->getValue(), $matches)) {
            throw ExpressionLanguageExceptionFactory::createForUnparsableToken($token);
        }

        $argumentEscaper = $this->argumentEscaper;

        $function = $matches['function'];
        if ('identity' === $function) {
            $value = preg_replace_callback(
                '/__ARG_TOKEN__[\da-z]{32}/',
                function (array $matches) use ($argumentEscaper): string {
                    return '\''.$argumentEscaper->unescape($matches[0]).'\'';
                },
                $matches['arguments']
            );

            $arguments = [new EvaluatedValue($value)];
        } elseif ('current' === $function) {
            $arguments = [new ValueForCurrentValue()];
        } else {
            $arguments = $this->parseArguments($this->parser, trim($matches['arguments']));
        }

        return new FunctionCallValue($function, $arguments);
    }
552204
public function setToken(string $token)
    {
        if (empty($selector)) {
            Throw new TokenException('Empty tokens are not allowed.');
        }

        $this->token = $token;
    }
770543
private void handleToken(String token) throws OptionParserException {
        currentToken = token;
        if (!"--".equals(token)) {
            if (currentOption != null && currentOption.acceptsValue() &&
                    !currentOption.isWithEqualSign() && isArgument(token)) {
                String t = OptionUtils.stripLeadingAndTrailingQuotes(token);
                currentOption.addValue(t);
            } else if (token.startsWith("--")) {
                String t = OptionUtils.stripLeadingHyphens(token);
                handleLongOption(t);
            } else if (token.startsWith("-") && token.length() > 1) {
                String t = OptionUtils.stripLeadingHyphens(token);
                handleShortAndLongOption(t);
            } else {
                handleUnknownToken(token);
            }
        }
        if (currentOption != null && !currentOption.acceptsValue()) {
            currentOption = null;
        }
    }
639330
public function replaceTokens($text, $tokens = [])
    {
        // Obtain Token Mappings:
        
        $mappings = $this->getTokenMappings();
        
        // Iterate Token Mappings:
        
        foreach ($mappings as $name => $spec) {
            
            // Ignore Custom Mappings:
            
            if (isset($spec['custom']) && $spec['custom']) {
                continue;
            }
            
            // Check Property Defined:
                
            if (!isset($spec['property'])) {
                throw new Exception(sprintf('Property is undefined for token mapping "%s"', $name));
            }
            
            // Obtain Value for Token:
            
            $value = isset($tokens[$name]) ? $tokens[$name] : $this->getPropertyValue($spec['property']);
            
            // Perform Token Replacement:
            
            $text = str_ireplace("{{$name}}", $value, $text);
            
        }
        
        // Answer Processed Text:
        
        return $text;
    }
583362
public function activateUser($token)
    {
        $activation = $this->getActivationByToken($token);

        if( $activation === null ) {
            throw new \Exception(trans('HCACL::users.activation.bad_token'));
        }

        $user = $this->getUser($activation);

        if( is_null($user) )
            throw new \Exception(trans('HCACL::users.activation.user_not_found'));

        // activate user
        $user->activate();

        // delete activation code
        $this->deleteActivation($token);

        // login user to the site
        auth()->login($user);
    }
486244
public function enterToken(array $token, $content)
    {
        switch ($token[Lexer::TYPE]) {
            case Lexer::T_ARRAY_CLOSE:
                return $this->parent;

            case Lexer::T_ARRAY_ARROW:
                $this->currentKey = array_pop($this->values);

                if (!is_scalar($this->currentKey)) {
                    throw new TokenException('array key must be scalar', $token);
                }
                break;

            case Lexer::T_QUOTED_STRING:
            case Lexer::T_NUMBER:
            case Lexer::T_TRUE:
            case Lexer::T_FALSE:
            case Lexer::T_NULL:
                $value = $this->getValueOfToken($token);
                $this->addValue($value);
                break;

            case Lexer::T_ARRAY_OPEN:
                $array = new ArrayContext($token, $this);
                $this->addValue($array);

                return $array;
                break;

            case Lexer::T_FUNC_OPEN:
                $func = new FuncContext($token, $this);
                $this->addValue($func);

                return $func;

            case Lexer::T_COMMA:
                if ($this->currentKey !== null) {
                    return null;
                }
                break;

            default:
                return null;
        }

        return $this;
    }
1189537
protected function checkToken($token)
    {
        if (!array_key_exists($token, $this->tokens)) {
            throw new TokenNotFoundException($token, get_called_class());
        }

        return $this->tokens[$token];
    }
769977
public function readLine($token = "\n")
  {
    $this->connect();

    $line = Str::factory("");

    while(!$line->endsWith($token))
    {
      $this->waitForReadyRead();

      $data = @fgets($this->stream, 4096);

      Signal::getInstance()->emit(strtolower($this->getAdapterType()) . "DataRead", $data);

      if($data === FALSE)
      {
        if($line->count())
        {
          $line->append($token);
        }
        else
        {
          throw new Exception("connection to server '" . $this->config["host"] . ":" . $this->config["port"] . "' lost");
        }
      }
      else
      {
        $line->append($data);
      }
    }

    return $line->trim();
  }
413788
protected function handleDoctype(array $token)
    {

        $node = $this->createNode('doctype', $token);
        $node->name = $token['name'];

        $this->current = $node;
    }
669404
public function addToken(Token $token)
    {
        $response = $this
            ->httpClient
            ->get(
                sprintf('/%s/tokens', $this->getAppUUID()->getId()),
                'put',
                [],
                $token->toArray(),
                Http::getApisearchHeaders($this)
            );

        self::throwTransportableExceptionIfNeeded($response);
    }
1004684
public function setToken($token)
    {
        $this->_tokenString = (string) $token;
        $this->_token       = $token;
        return $this;
    }
838359
protected function handleText(array $token)
    {

        $node = $this->createNode('text', $token);
        $node->value = $token['value'];
        $node->level = $token['level'];
        $node->escaped = $token['escaped'];

        if ($this->current) {

            $this->current->append($node);
        } else
            $this->current = $node;
    }
732776
private function parseArgument($token)
    {
        $c = \count($this->arguments);

        // if input is expecting another argument, add it
        if ($this->definition->hasArgument($c)) {
            $arg = $this->definition->getArgument($c);
            $this->arguments[$arg->getName()] = $arg->isArray() ? [$token] : $token;

        // if last argument isArray(), append token to last argument
        } elseif ($this->definition->hasArgument($c - 1) && $this->definition->getArgument($c - 1)->isArray()) {
            $arg = $this->definition->getArgument($c - 1);
            $this->arguments[$arg->getName()][] = $token;

        // unexpected argument
        } else {
            $all = $this->definition->getArguments();
            if (\count($all)) {
                throw new RuntimeException(sprintf('Too many arguments, expected arguments "%s".', implode('" "', array_keys($all))));
            }

            throw new RuntimeException(sprintf('No arguments expected, got "%s".', $token));
        }
    }
215703
static public function load($token = null)
    {
        // if single token is set, we keep it
        if (is_null($token) && static::hasSingleToken()) {
            $token = static::getSingleToken();
        }

        // if no session are set, we set a new one only is class has a singleToken
        if (!Session::has($token)){
            if (static::hasSingleToken()) {
                Session::push($token, json_encode(['constructor' => static::class]));
            } else {
                throw new \InvalidArgumentException('Token "' . $token . '" is not valid');
            }
        }

        // load configuration
        $config = Session::get($token);
        $config = json_decode($config[0], true);
        $constructor = $config['constructor'];

        // construct Table polliwog
        if (preg_match('#(?<class>.+)::(?<method>.+)#', $constructor, $match)) {

            $method = $match['method'];
            // extract parameters
            $params = [];
            if (preg_match('#(?<method>[^:]+):(?<params>.+)#', $method, $params)) {
                $method = $params['method'];
                $params = explode(',', $params['params']);
            }

            $table =  call_user_func_array([$match['class'], $method], $params);
        } else {
            $instance = new \ReflectionClass($config->constructor);
            $table = $instance->newInstance();
        }

        // validate that instance is viable
        if (!($table instanceof static)) {
            throw new \Exception('Loaded instance is not viable');
        }

        return $table;
    }
249346
public function parse(Token $token)
    {
        parent::parse($token);

        $split = preg_split(self::REGEX, $token->getValue(), 2, PREG_SPLIT_DELIM_CAPTURE + PREG_SPLIT_NO_EMPTY);
        $splitSize = count($split);
        if (1 === $splitSize) {
            return $this->functionTokenParser->parse($token);
        }

        if (3 !== count($split) && 4 !== count($split)) {
            throw ExpressionLanguageExceptionFactory::createForCouldNotLexValue($token->getValue());
        }

        $values = [
            $this->parser->parse($split[0].$split[1]),
        ];
        if (3 === $splitSize) {
            $values[] = $this->parser->parse('<'.$split[2]);
        }

        if (4 === $splitSize) {
            $values[] = $this->parser->parse($split[2]);
            $values[] = $this->parser->parse('<'.$split[3]);
        }

        return $this->mergeValues($values);
    }