Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/parser/expr.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,9 @@ module.exports = {
if (this.token === this.tok.T_SPACESHIP) {
return result("bin", "<=>", expr, this.next().read_expr());
}
if (this.token === this.tok.T_NULLSAFE_OBJECT_OPERATOR) {
return result("nullsafepropertylookup", expr, this.read_what());
}

if (this.token === this.tok.T_INSTANCEOF) {
expr = result(
Expand Down
25 changes: 25 additions & 0 deletions test/snapshot/__snapshots__/call.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -1119,6 +1119,31 @@ Program {
}
`;

exports[`Test call nullsafepropertylookup (3) 1`] = `
Program {
"children": [
ExpressionStatement {
"expression": NullSafePropertyLookup {
"kind": "nullsafepropertylookup",
"offset": Identifier {
"kind": "identifier",
"name": "property",
},
"what": Variable {
"curly": false,
"kind": "variable",
"name": "obj",
"parenthesizedExpression": true,
},
},
"kind": "expressionstatement",
},
],
"errors": [],
"kind": "program",
}
`;

exports[`Test call nullsafepropertylookup 1`] = `
Program {
"children": [
Expand Down
6 changes: 6 additions & 0 deletions test/snapshot/call.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,12 @@ describe("Test call", function () {
});
expect(ast).toMatchSnapshot();
});
it("nullsafepropertylookup (3)", function () {
const ast = parser.parseEval("($obj)?->property;", {
parser: { debug: false },
});
expect(ast).toMatchSnapshot();
});
it("staticlookup", function () {
const ast = parser.parseEval("$obj::call();", {
parser: { debug: false },
Expand Down