Skip to content
This repository was archived by the owner on Mar 29, 2023. It is now read-only.

Commit fd8d0dc

Browse files
committed
fix - use ExpressionStatement on static:: calls
1 parent 1030beb commit fd8d0dc

File tree

4 files changed

+34
-28
lines changed

4 files changed

+34
-28
lines changed

src/ast/this.js

Whitespace-only changes.

src/parser/statement.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -253,20 +253,20 @@ module.exports = {
253253

254254
case this.tok.T_STATIC:
255255
current = [this.token, this.lexer.getState()];
256-
result = this.node("static");
256+
result = this.node();
257257
if (this.next().token === this.tok.T_DOUBLE_COLON) {
258258
// static keyword for a class
259259
this.lexer.tokens.push(current);
260260
expr = this.next().read_expr();
261-
this.expect(";") && this.next();
262-
return expr;
261+
this.expectEndOfStatement(expr);
262+
return result("expressionstatement", expr);
263263
}
264264
if (this.token === this.tok.T_FUNCTION) {
265265
return this.read_function(true, [0, 1, 0]);
266266
}
267267
items = this.read_variable_declarations();
268268
this.expectEndOfStatement();
269-
return result(items);
269+
return result("static", items);
270270

271271
case this.tok.T_ECHO: {
272272
result = this.node("echo");

test/snapshot/__snapshots__/class.test.js.snap

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -305,20 +305,23 @@ Program {
305305
},
306306
},
307307
},
308-
Call {
309-
"arguments": Array [],
310-
"kind": "call",
311-
"what": StaticLookup {
312-
"kind": "staticlookup",
313-
"offset": Identifier {
314-
"kind": "identifier",
315-
"name": "baz",
316-
},
317-
"what": Identifier {
318-
"kind": "identifier",
319-
"name": "static",
308+
ExpressionStatement {
309+
"expression": Call {
310+
"arguments": Array [],
311+
"kind": "call",
312+
"what": StaticLookup {
313+
"kind": "staticlookup",
314+
"offset": Identifier {
315+
"kind": "identifier",
316+
"name": "baz",
317+
},
318+
"what": Identifier {
319+
"kind": "identifier",
320+
"name": "static",
321+
},
320322
},
321323
},
324+
"kind": "expressionstatement",
322325
},
323326
Call {
324327
"arguments": Array [],

test/snapshot/__snapshots__/variable.test.js.snap

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -275,20 +275,23 @@ Program {
275275
exports[`Test variables Class constants 1`] = `
276276
Program {
277277
"children": Array [
278-
Call {
279-
"arguments": Array [],
280-
"kind": "call",
281-
"what": StaticLookup {
282-
"kind": "staticlookup",
283-
"offset": Identifier {
284-
"kind": "identifier",
285-
"name": "foo",
286-
},
287-
"what": Identifier {
288-
"kind": "identifier",
289-
"name": "static",
278+
ExpressionStatement {
279+
"expression": Call {
280+
"arguments": Array [],
281+
"kind": "call",
282+
"what": StaticLookup {
283+
"kind": "staticlookup",
284+
"offset": Identifier {
285+
"kind": "identifier",
286+
"name": "foo",
287+
},
288+
"what": Identifier {
289+
"kind": "identifier",
290+
"name": "static",
291+
},
290292
},
291293
},
294+
"kind": "expressionstatement",
292295
},
293296
Call {
294297
"arguments": Array [],

0 commit comments

Comments
 (0)