Parses a token and returns a node.

@param Token $token A Twig_Token instance

@return Node A Twig_Node instance
429547
public function parse(Token $token)
    {
        $lineno = $token->getLine();
        $stream = $this->parser->getStream();

        $stream->expect(Token::BLOCK_END_TYPE);
        $try = $this->parser->subparse([$this, 'decideCatch']);
        $stream->next();
        $stream->expect(Token::BLOCK_END_TYPE);
        $catch = $this->parser->subparse([$this, 'decideEnd']);
        $stream->next();
        $stream->expect(Token::BLOCK_END_TYPE);

        return new TwigNodeTryCatch($try, $catch, $lineno, $this->getTag());
    }
859422
protected static function parseArgument( $token )
	{
		$description = null;

		if ( Str::contains( $token, ' : ' ) )
		{
			list( $token, $description ) = explode( ' : ', $token, 2 );

			$token = trim( $token );

			$description = trim( $description );
		}

		switch ( true )
		{
			case Str::endsWith( $token, '?*' ):
				return new InputArgument( trim( $token, '?*' ), InputArgument::IS_ARRAY, $description );
			case Str::endsWith( $token, '*' ):
				return new InputArgument( trim( $token, '*' ), InputArgument::IS_ARRAY | InputArgument::REQUIRED, $description );
			case Str::endsWith( $token, '?' ):
				return new InputArgument( trim( $token, '?' ), InputArgument::OPTIONAL, $description );
			case preg_match( '/(.+)\=(.+)/', $token, $matches ):
				return new InputArgument( $matches[1], InputArgument::OPTIONAL, $description, $matches[2] );
			default:
				return new InputArgument( $token, InputArgument::REQUIRED, $description );
		}
	}
365459
public function parse(Twig_Token $token)
    {
        $name = $this->parser->getVarName();
        $ref = new Twig_Node_Expression_BlockReference(new Twig_Node_Expression_Constant($name, $token->getLine()), true, $token->getLine(), $this->getTag());

        $filter = $this->parser->getExpressionParser()->parseFilterExpressionRaw($ref, $this->getTag());
        $this->parser->getStream()->expect(Twig_Token::BLOCK_END_TYPE);

        $body = $this->parser->subparse(array($this, 'decideBlockEnd'), true);
        $this->parser->getStream()->expect(Twig_Token::BLOCK_END_TYPE);

        $block = new Twig_Node_Block($name, $body, $token->getLine());
        $this->parser->setBlock($name, $block);

        return new Twig_Node_Print($filter, $token->getLine(), $this->getTag());
    }
1275442
public function parse(Token $token): string
    {
        $value = $token->getValue();
        if ('' === $value) {
            throw ExpressionLanguageExceptionFactory::createForUnparsableToken($token);
        }

        return $this->tokenizer->detokenize(substr($value, 1));
    }
791283
public function fetchToken(string $token) : ?Token
    {
        return $this->getModel()
                    ->newQuery()
                    ->where('token', $token)
                    ->first();
    }
1345097
public function parse(Twig_Token $token)
    {
        $options = array();
        $stream = $this->parser->getStream();
        $start = $stream->getCurrent();
        $arguments = array();
        do {
            $value = $this->parser->getExpressionParser()->parseExpression();
            if ($stream->test('as')) {
                $stream->expect('as');
                $name = $stream->expect(Twig_Token::NAME_TYPE)->getValue();
            } else {
                $name = null;
            }
            $arguments[] = array('name' => $name, 'value' => $value);

            $end = !$stream->test(Twig_Token::PUNCTUATION_TYPE, ',');
            if (!$end) {
                $stream->expect(Twig_Token::PUNCTUATION_TYPE, ',');
            }
        } while (!$end);

        while ($stream->test($this->options)) {
            $options[] = $stream->expect($this->options)->getValue();
        }

        $stream->expect(Twig_Token::BLOCK_END_TYPE);
        $body = $this->parser->subparse(array($this, 'decideWithEnd'), true);
        $stream->expect(Twig_Token::BLOCK_END_TYPE);
        return new WithNode($arguments, $body, $options, $start->getLine(), $start->getValue());
    }
1123514
protected function getUserByToken($token) {
		$response = $this->getHttpClient()->request('GET', 'https://openapi.naver.com/v1/nid/getUserProfile.xml', [
			'headers' => [
				'Authorization' => 'Bearer ' . $token,
		    ],
		]);
		
		$xml = $response->getBody()->getContents();
		
		return $this->parseXML($xml)['response'];
		
	}
1373854
public function userFromToken(string $token)
    {
        $user = $this->mapUserToObject($this->getUserByToken($token));
        return $user->setToken($token);
    }
152505
public function parse(Twig_Token $token)
    {
        $stream = $this->parser->getStream();
        $stream->expect(Twig_Token::BLOCK_END_TYPE);
        return new DefaultNode($token->getLine(), $this->getTag());
    }
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);
    }
1024594
public function parse(Twig_Token $token)
    {
        $lineno = $token->getLine();
        $stream = $this->parser->getStream();
        $reference = $stream->expect(Twig_Token::NAME_TYPE)->getValue();

        $name = $stream->nextIf(\Twig_Token::STRING_TYPE);
        $name = $name !== null ? $name->getValue() : false;

        $unique = $name !== false;

        $variableName = $stream->nextIf(\Twig_Token::NAME_TYPE);
        $variableName = $variableName !== null ? $variableName->getValue() : false;

        $offset = $stream->nextIf(\Twig_Token::NUMBER_TYPE);
        $offset = $offset !== null ? $offset->getValue() : false;

        if ($name) {
            $name = $this->blockPrefix . $reference . $name;
            if ($this->parser->hasBlock($name)) {
                $this->bodyParse($stream, $name);

                return null;
            }
        } else {
            $name = $this->createUniqueBlockName($token, $reference);
        }

        $this->parser->setBlock($name, $block = new Node\Defer($name, new Twig_Node(array()), $lineno));
        $this->parser->pushLocalScope();

        $body = $this->bodyParse($stream, $name);

        $block->setNode('body', $body);
        $this->parser->popLocalScope();

        return new Node\DeferReference($name, $variableName, $unique, $reference, $offset, $lineno, $this->getTag());
    }
1033477
protected static function parseArgument($token)
    {
        list($token, $description) = static::extractDescription($token);

        switch (true) {
            case Str::endsWith($token, '?*'):
                return new InputArgument(trim($token, '?*'), InputArgument::IS_ARRAY, $description);
            case Str::endsWith($token, '*'):
                return new InputArgument(trim($token, '*'), InputArgument::IS_ARRAY | InputArgument::REQUIRED, $description);
            case Str::endsWith($token, '?'):
                return new InputArgument(trim($token, '?'), InputArgument::OPTIONAL, $description);
            case preg_match('/(.+)\=\*(.+)/', $token, $matches):
                return new InputArgument($matches[1], InputArgument::IS_ARRAY, $description, preg_split('/,\s?/', $matches[2]));
            case preg_match('/(.+)\=(.+)/', $token, $matches):
                return new InputArgument($matches[1], InputArgument::OPTIONAL, $description, $matches[2]);
            default:
                return new InputArgument($token, InputArgument::REQUIRED, $description);
        }
    }
758126
public function parse(Token $token)
    {
        $lineno = $token->getLine();
        $stream = $this->parser->getStream();

        $form = $this->parser->getExpressionParser()->parseExpression();
        $only = false;

        if ($this->parser->getStream()->test(Token::NAME_TYPE, 'with')) {
            $this->parser->getStream()->next();
            $resources = $this->parser->getExpressionParser()->parseExpression();

            if ($this->parser->getStream()->nextIf(Token::NAME_TYPE, 'only')) {
                $only = true;
            }
        } else {
            $resources = new ArrayExpression([], $stream->getCurrent()->getLine());
            do {
                $resources->addElement($this->parser->getExpressionParser()->parseExpression());
            } while (!$stream->test(Token::BLOCK_END_TYPE));
        }

        $stream->expect(Token::BLOCK_END_TYPE);

        return new FormThemeNode($form, $resources, $lineno, $this->getTag(), $only);
    }
251098
public function getPayload($token)
    {
        try {
            $jws = SimpleJWS::load($token);

            return $jws->getPayload();
        } catch (\InvalidArgumentException $ex) {
            throw new ProgrammerException('Unable to read jws token.', ProgrammerException::JWS_INVALID_TOKEN_FORMAT);
        }
    }
1004684
public function setToken($token)
    {
        $this->_tokenString = (string) $token;
        $this->_token       = $token;
        return $this;
    }
1002931
public function tokenConsumed(Token $token)
    {
        $this->eventDispatcher->dispatch(
            TokenEvents::TOKEN_CONSUMED,
            $event = new TokenConsumedEvent($token)
        );

        return $event;
    }
207583
public function parse( Twig_Token $token ) {

		$nodes  = array();
		$parser = $this->parser;
		$stream = $parser->getStream();

		$stream->expect( Twig_Token::BLOCK_END_TYPE );
		$nodes['callback'] = $parser->subparse( array( $this, 'decide_comments_end' ), true );
		$stream->expect( Twig_Token::BLOCK_END_TYPE );

		return new Comments_Node( $nodes, array(), $token->getLine(), $this->getTag() );
	}