mirror of
https://github.com/danog/parser.git
synced 2025-01-22 13:01:32 +01:00
parser: support first class callables on static method calls
This commit is contained in:
parent
8d6ad8ec0a
commit
17b37157ce
@ -2110,6 +2110,16 @@ impl Parser {
|
||||
unpack = true;
|
||||
}
|
||||
|
||||
if unpack && self.current.kind == TokenKind::RightParen {
|
||||
args.push(Arg {
|
||||
name: None,
|
||||
unpack: false,
|
||||
value: Expression::VariadicPlaceholder
|
||||
});
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
let value = self.expression(Precedence::Lowest)?;
|
||||
|
||||
args.push(Arg {
|
||||
@ -4045,6 +4055,19 @@ mod tests {
|
||||
]);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn first_class_callable_static_method() {
|
||||
assert_ast("<?php A::foo(...);", &[
|
||||
expr!(Expression::StaticMethodCall { target: Box::new(Expression::Identifier { name: "A".into() }), method: "foo".into(), args: vec![
|
||||
Arg {
|
||||
name: None,
|
||||
unpack: false,
|
||||
value: Expression::VariadicPlaceholder
|
||||
}
|
||||
] })
|
||||
]);
|
||||
}
|
||||
|
||||
fn assert_ast(source: &str, expected: &[Statement]) {
|
||||
let mut lexer = Lexer::new(None);
|
||||
let tokens = lexer.tokenize(source).unwrap();
|
||||
|
Loading…
x
Reference in New Issue
Block a user