Skip to content

Commit f536fc6

Browse files
authored
Merge pull request microsoft#149 from Microsoft/newStaticError
Fix microsoft#148 - parse `new static` without errors
2 parents 403bc8e + c993bc6 commit f536fc6

File tree

5 files changed

+141
-1
lines changed

5 files changed

+141
-1
lines changed

src/Parser.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2397,11 +2397,11 @@ private function parseObjectCreationExpression($parentNode) {
23972397
$this->isParsingObjectCreationExpression = true;
23982398
$objectCreationExpression->classTypeDesignator =
23992399
$this->eatOptional(TokenKind::ClassKeyword) ??
2400+
$this->eatOptional(TokenKind::StaticKeyword) ??
24002401
$this->parseExpression($objectCreationExpression);
24012402

24022403
$this->isParsingObjectCreationExpression = false;
24032404

2404-
24052405
$objectCreationExpression->openParen = $this->eatOptional(TokenKind::OpenParenToken);
24062406
if ($objectCreationExpression->openParen !== null) {
24072407
$objectCreationExpression->argumentExpressionList = $this->parseArgumentExpressionList($objectCreationExpression);
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<?php
2+
3+
$a = new static;
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
{
2+
"SourceFileNode": {
3+
"statementList": [
4+
{
5+
"InlineHtml": {
6+
"scriptSectionEndTag": null,
7+
"text": null,
8+
"scriptSectionStartTag": {
9+
"kind": "ScriptSectionStartTag",
10+
"textLength": 6
11+
}
12+
}
13+
},
14+
{
15+
"ExpressionStatement": {
16+
"expression": {
17+
"AssignmentExpression": {
18+
"leftOperand": {
19+
"Variable": {
20+
"dollar": null,
21+
"name": {
22+
"kind": "VariableName",
23+
"textLength": 2
24+
}
25+
}
26+
},
27+
"operator": {
28+
"kind": "EqualsToken",
29+
"textLength": 1
30+
},
31+
"byRef": null,
32+
"rightOperand": {
33+
"ObjectCreationExpression": {
34+
"newKeword": {
35+
"kind": "NewKeyword",
36+
"textLength": 3
37+
},
38+
"classTypeDesignator": {
39+
"kind": "StaticKeyword",
40+
"textLength": 6
41+
},
42+
"openParen": null,
43+
"argumentExpressionList": null,
44+
"closeParen": null,
45+
"classBaseClause": null,
46+
"classInterfaceClause": null,
47+
"classMembers": null
48+
}
49+
}
50+
}
51+
},
52+
"semicolon": {
53+
"kind": "SemicolonToken",
54+
"textLength": 1
55+
}
56+
}
57+
}
58+
],
59+
"endOfFileToken": {
60+
"kind": "EndOfFileToken",
61+
"textLength": 0
62+
}
63+
}
64+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<?php
2+
3+
$a = new static();
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
{
2+
"SourceFileNode": {
3+
"statementList": [
4+
{
5+
"InlineHtml": {
6+
"scriptSectionEndTag": null,
7+
"text": null,
8+
"scriptSectionStartTag": {
9+
"kind": "ScriptSectionStartTag",
10+
"textLength": 6
11+
}
12+
}
13+
},
14+
{
15+
"ExpressionStatement": {
16+
"expression": {
17+
"AssignmentExpression": {
18+
"leftOperand": {
19+
"Variable": {
20+
"dollar": null,
21+
"name": {
22+
"kind": "VariableName",
23+
"textLength": 2
24+
}
25+
}
26+
},
27+
"operator": {
28+
"kind": "EqualsToken",
29+
"textLength": 1
30+
},
31+
"byRef": null,
32+
"rightOperand": {
33+
"ObjectCreationExpression": {
34+
"newKeword": {
35+
"kind": "NewKeyword",
36+
"textLength": 3
37+
},
38+
"classTypeDesignator": {
39+
"kind": "StaticKeyword",
40+
"textLength": 6
41+
},
42+
"openParen": {
43+
"kind": "OpenParenToken",
44+
"textLength": 1
45+
},
46+
"argumentExpressionList": null,
47+
"closeParen": {
48+
"kind": "CloseParenToken",
49+
"textLength": 1
50+
},
51+
"classBaseClause": null,
52+
"classInterfaceClause": null,
53+
"classMembers": null
54+
}
55+
}
56+
}
57+
},
58+
"semicolon": {
59+
"kind": "SemicolonToken",
60+
"textLength": 1
61+
}
62+
}
63+
}
64+
],
65+
"endOfFileToken": {
66+
"kind": "EndOfFileToken",
67+
"textLength": 0
68+
}
69+
}
70+
}

0 commit comments

Comments
 (0)