use Symfony\Component\ExpressionLanguage\Node\GetAttrNode;
use Symfony\Component\ExpressionLanguage\Node\NameNode;
class GetAttrNodeTest extends AbstractNodeTestCase
{ public static function getEvaluateData(): array
{ return [ ['b',
new GetAttrNode(new NameNode('foo'
),
new ConstantNode(0
), self::
getArrayNode(), GetAttrNode::ARRAY_CALL
),
['foo' =>
['b' => 'a', 'b'
]]],
['a',
new GetAttrNode(new NameNode('foo'
),
new ConstantNode('b'
), self::
getArrayNode(), GetAttrNode::ARRAY_CALL
),
['foo' =>
['b' => 'a', 'b'
]]],
['bar',
new GetAttrNode(new NameNode('foo'
),
new ConstantNode('foo'
), self::
getArrayNode(), GetAttrNode::PROPERTY_CALL
),
['foo' =>
new Obj()]],
['baz',
new GetAttrNode(new NameNode('foo'
),
new ConstantNode('foo'
), self::
getArrayNode(), GetAttrNode::METHOD_CALL
),
['foo' =>
new Obj()]],
['a',
new GetAttrNode(new NameNode('foo'
),
new NameNode('index'
), self::
getArrayNode(), GetAttrNode::ARRAY_CALL
),
['foo' =>
['b' => 'a', 'b'
], 'index' => 'b'
]],
];
} public static function getCompileData(): array
{ return [ ['$foo[0]',
new GetAttrNode(new NameNode('foo'
),
new ConstantNode(0
), self::
getArrayNode(), GetAttrNode::ARRAY_CALL
)],
['$foo["b"]',
new GetAttrNode(new NameNode('foo'
),
new ConstantNode('b'
), self::
getArrayNode(), GetAttrNode::ARRAY_CALL
)],
[