ArgumentsNode example

                    //                     // Other types, such as STRING_TYPE and NUMBER_TYPE, can't be parsed as property nor method names.                     //                     // As a result, if $token is NOT an operator OR $token->value is NOT a valid property or method name, an exception shall be thrown.                     && (Token::OPERATOR_TYPE !== $token->type || !preg_match('/[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*/A', $token->value))
                ) {
                    throw new SyntaxError('Expected name.', $token->cursor, $this->stream->getExpression());
                }

                $arg = new Node\ConstantNode($token->value, true, $isNullSafe);

                $arguments = new Node\ArgumentsNode();
                if ($this->stream->current->test(Token::PUNCTUATION_TYPE, '(')) {
                    $type = Node\GetAttrNode::METHOD_CALL;
                    foreach ($this->parseArguments()->nodes as $n) {
                        $arguments->addElement($n);
                    }
                } else {
                    $type = Node\GetAttrNode::PROPERTY_CALL;
                }

                $node = new Node\GetAttrNode($node$arg$arguments$type);
            } elseif ('[' === $token->value) {
                

    public function testParse($node$expression$names = [])
    {
        $lexer = new Lexer();
        $parser = new Parser([]);
        $this->assertEquals($node$parser->parse($lexer->tokenize($expression)$names));
    }

    public static function getParseData()
    {
        $arguments = new Node\ArgumentsNode();
        $arguments->addElement(new Node\ConstantNode('arg1'));
        $arguments->addElement(new Node\ConstantNode(2));
        $arguments->addElement(new Node\ConstantNode(true));

        $arrayNode = new Node\ArrayNode();
        $arrayNode->addElement(new Node\NameNode('bar'));

        return [
            [
                new Node\NameNode('a'),
                'a',
                [


    public static function getDumpData(): \Generator
    {
        yield from [
            ['"a", "b"', static::getArrayNode()],
        ];
    }

    protected static function createArrayNode(): \Symfony\Component\ExpressionLanguage\Node\ArrayNode
    {
        return new ArgumentsNode();
    }
}
Home | Imprint | This part of the site doesn't use cookies.