mirror of
https://github.com/danog/parser.git
synced 2024-11-30 04:29:13 +01:00
Merge pull request #52 from ryangjchandler/fix/nullsafe-property-fetch
This commit is contained in:
commit
b070f7b07b
@ -237,7 +237,7 @@ impl Lexer {
|
||||
TokenKind::QuestionColon
|
||||
} else if self.try_read("->") {
|
||||
self.col += 1;
|
||||
self.skip(3);
|
||||
self.skip(2);
|
||||
TokenKind::NullsafeArrow
|
||||
} else {
|
||||
TokenKind::Question
|
||||
|
@ -3177,6 +3177,17 @@ mod tests {
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn nullsafe_operator() {
|
||||
assert_ast(
|
||||
"<?php $a?->b;",
|
||||
&[expr!(Expression::NullsafePropertyFetch {
|
||||
target: Box::new(Expression::Variable { name: "a".into() }),
|
||||
property: Box::new(Expression::Identifier { name: "b".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