Fix #148 - parse `new static` without errors

This commit is contained in:
Rob Lourens 2017-06-12 17:33:26 -07:00
Родитель 403bc8e9a4
Коммит c993bc6160
5 изменённых файлов: 141 добавлений и 1 удалений

Просмотреть файл

@ -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
}
}
}