mirror of
https://github.com/danog/parser.git
synced 2024-11-30 04:29:13 +01:00
parser: support static variable variable property fetches
This commit is contained in:
parent
c91d7a495f
commit
15e84edab6
@ -2099,7 +2099,7 @@ impl Parser {
|
||||
}
|
||||
}
|
||||
TokenKind::DoubleColon => match self.current.kind.clone() {
|
||||
TokenKind::Variable(_) => {
|
||||
TokenKind::Dollar | TokenKind::Variable(_) => {
|
||||
let var = self.expression(Precedence::Lowest)?;
|
||||
|
||||
Expression::StaticPropertyFetch {
|
||||
@ -4268,6 +4268,20 @@ mod tests {
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn variable_variable_static_property_fetch() {
|
||||
assert_ast("<?php Foo::$$a;", &[
|
||||
expr!(Expression::StaticPropertyFetch {
|
||||
target: Box::new(Expression::Identifier { name: "Foo".into() }),
|
||||
property: Box::new(Expression::DynamicVariable {
|
||||
name: Box::new(Expression::Variable {
|
||||
name: "a".into()
|
||||
})
|
||||
})
|
||||
})
|
||||
]);
|
||||
}
|
||||
|
||||
fn assert_ast(source: &str, expected: &[Statement]) {
|
||||
let mut lexer = Lexer::new(None);
|
||||
let tokens = lexer.tokenize(source).unwrap();
|
||||
|
Loading…
Reference in New Issue
Block a user