Fix #148 - parse `new static` without errors
This commit is contained in:
Родитель
403bc8e9a4
Коммит
c993bc6160
|
@ -2397,11 +2397,11 @@ class Parser {
|
|||
$this->isParsingObjectCreationExpression = true;
|
||||
$objectCreationExpression->classTypeDesignator =
|
||||
$this->eatOptional(TokenKind::ClassKeyword) ??
|
||||
$this->eatOptional(TokenKind::StaticKeyword) ??
|
||||
$this->parseExpression($objectCreationExpression);
|
||||
|
||||
$this->isParsingObjectCreationExpression = false;
|
||||
|
||||
|
||||
$objectCreationExpression->openParen = $this->eatOptional(TokenKind::OpenParenToken);
|
||||
if ($objectCreationExpression->openParen !== null) {
|
||||
$objectCreationExpression->argumentExpressionList = $this->parseArgumentExpressionList($objectCreationExpression);
|
||||
|
|
|
@ -0,0 +1,3 @@
|
|||
<?php
|
||||
|
||||
$a = new static;
|
|
@ -0,0 +1,64 @@
|
|||
{
|
||||
"SourceFileNode": {
|
||||
"statementList": [
|
||||
{
|
||||
"InlineHtml": {
|
||||
"scriptSectionEndTag": null,
|
||||
"text": null,
|
||||
"scriptSectionStartTag": {
|
||||
"kind": "ScriptSectionStartTag",
|
||||
"textLength": 6
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"ExpressionStatement": {
|
||||
"expression": {
|
||||
"AssignmentExpression": {
|
||||
"leftOperand": {
|
||||
"Variable": {
|
||||
"dollar": null,
|
||||
"name": {
|
||||
"kind": "VariableName",
|
||||
"textLength": 2
|
||||
}
|
||||
}
|
||||
},
|
||||
"operator": {
|
||||
"kind": "EqualsToken",
|
||||
"textLength": 1
|
||||
},
|
||||
"byRef": null,
|
||||
"rightOperand": {
|
||||
"ObjectCreationExpression": {
|
||||
"newKeword": {
|
||||
"kind": "NewKeyword",
|
||||
"textLength": 3
|
||||
},
|
||||
"classTypeDesignator": {
|
||||
"kind": "StaticKeyword",
|
||||
"textLength": 6
|
||||
},
|
||||
"openParen": null,
|
||||
"argumentExpressionList": null,
|
||||
"closeParen": null,
|
||||
"classBaseClause": null,
|
||||
"classInterfaceClause": null,
|
||||
"classMembers": null
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"semicolon": {
|
||||
"kind": "SemicolonToken",
|
||||
"textLength": 1
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
"endOfFileToken": {
|
||||
"kind": "EndOfFileToken",
|
||||
"textLength": 0
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,3 @@
|
|||
<?php
|
||||
|
||||
$a = new static();
|
|
@ -0,0 +1,70 @@
|
|||
{
|
||||
"SourceFileNode": {
|
||||
"statementList": [
|
||||
{
|
||||
"InlineHtml": {
|
||||
"scriptSectionEndTag": null,
|
||||
"text": null,
|
||||
"scriptSectionStartTag": {
|
||||
"kind": "ScriptSectionStartTag",
|
||||
"textLength": 6
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"ExpressionStatement": {
|
||||
"expression": {
|
||||
"AssignmentExpression": {
|
||||
"leftOperand": {
|
||||
"Variable": {
|
||||
"dollar": null,
|
||||
"name": {
|
||||
"kind": "VariableName",
|
||||
"textLength": 2
|
||||
}
|
||||
}
|
||||
},
|
||||
"operator": {
|
||||
"kind": "EqualsToken",
|
||||
"textLength": 1
|
||||
},
|
||||
"byRef": null,
|
||||
"rightOperand": {
|
||||
"ObjectCreationExpression": {
|
||||
"newKeword": {
|
||||
"kind": "NewKeyword",
|
||||
"textLength": 3
|
||||
},
|
||||
"classTypeDesignator": {
|
||||
"kind": "StaticKeyword",
|
||||
"textLength": 6
|
||||
},
|
||||
"openParen": {
|
||||
"kind": "OpenParenToken",
|
||||
"textLength": 1
|
||||
},
|
||||
"argumentExpressionList": null,
|
||||
"closeParen": {
|
||||
"kind": "CloseParenToken",
|
||||
"textLength": 1
|
||||
},
|
||||
"classBaseClause": null,
|
||||
"classInterfaceClause": null,
|
||||
"classMembers": null
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"semicolon": {
|
||||
"kind": "SemicolonToken",
|
||||
"textLength": 1
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
"endOfFileToken": {
|
||||
"kind": "EndOfFileToken",
|
||||
"textLength": 0
|
||||
}
|
||||
}
|
||||
}
|
Загрузка…
Ссылка в новой задаче