mirror of
https://github.com/danog/parser.git
synced 2025-01-22 21:11:55 +01:00
chore: format
This commit is contained in:
parent
b4b4e8340e
commit
dab4b9d8f4
@ -2224,7 +2224,11 @@ impl Parser {
|
||||
self.rparen()?;
|
||||
|
||||
if op == &TokenKind::NullsafeArrow {
|
||||
Expression::NullsafeMethodCall { target: Box::new(lhs), method: Box::new(property), args }
|
||||
Expression::NullsafeMethodCall {
|
||||
target: Box::new(lhs),
|
||||
method: Box::new(property),
|
||||
args,
|
||||
}
|
||||
} else {
|
||||
Expression::MethodCall {
|
||||
target: Box::new(lhs),
|
||||
@ -3499,44 +3503,45 @@ mod tests {
|
||||
|
||||
#[test]
|
||||
fn nullsafe_method_calls() {
|
||||
assert_ast("<?php $a?->b();", &[
|
||||
expr!(Expression::NullsafeMethodCall {
|
||||
assert_ast(
|
||||
"<?php $a?->b();",
|
||||
&[expr!(Expression::NullsafeMethodCall {
|
||||
target: Box::new(Expression::Variable { name: "a".into() }),
|
||||
method: Box::new(Expression::Identifier { name: "b".into() }),
|
||||
args: vec![],
|
||||
})
|
||||
]);
|
||||
})],
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn nullsafe_method_calls_with_args() {
|
||||
assert_ast("<?php $a?->b($c);", &[
|
||||
expr!(Expression::NullsafeMethodCall {
|
||||
assert_ast(
|
||||
"<?php $a?->b($c);",
|
||||
&[expr!(Expression::NullsafeMethodCall {
|
||||
target: Box::new(Expression::Variable { name: "a".into() }),
|
||||
method: Box::new(Expression::Identifier { name: "b".into() }),
|
||||
args: vec![
|
||||
Arg {
|
||||
name: None,
|
||||
unpack: false,
|
||||
value: Expression::Variable { name: "c".into() }
|
||||
}
|
||||
],
|
||||
})
|
||||
]);
|
||||
args: vec![Arg {
|
||||
name: None,
|
||||
unpack: false,
|
||||
value: Expression::Variable { name: "c".into() }
|
||||
}],
|
||||
})],
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn nullsafe_method_call_chain() {
|
||||
assert_ast("<?php $a?->b?->c();", &[
|
||||
expr!(Expression::NullsafeMethodCall {
|
||||
assert_ast(
|
||||
"<?php $a?->b?->c();",
|
||||
&[expr!(Expression::NullsafeMethodCall {
|
||||
target: Box::new(Expression::NullsafePropertyFetch {
|
||||
target: Box::new(Expression::Variable { name: "a".into() }),
|
||||
property: Box::new(Expression::Identifier { name: "b".into() }),
|
||||
}),
|
||||
method: Box::new(Expression::Identifier { name: "c".into() }),
|
||||
args: vec![],
|
||||
})
|
||||
]);
|
||||
})],
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
Loading…
x
Reference in New Issue
Block a user