Make remainingTargetNames consistent, avoid php notice
Add a test of parsing an empty `insteadof` clause Make remainingTargetNames consistently be an empty array instead of null
This commit is contained in:
Родитель
f297043862
Коммит
797f79578d
|
@ -2950,15 +2950,15 @@ class Parser {
|
|||
if ($traitSelectAndAliasClause->asOrInsteadOfKeyword->kind === TokenKind::InsteadOfKeyword) {
|
||||
// https://github.com/Microsoft/tolerant-php-parser/issues/190
|
||||
// TODO: In the next backwards incompatible release, convert targetName to a list?
|
||||
$interfaceNameList = $this->parseQualifiedNameList($traitSelectAndAliasClause)->children;
|
||||
$traitSelectAndAliasClause->targetName = $interfaceNameList[0] ?? null;
|
||||
$interfaceNameList = $this->parseQualifiedNameList($traitSelectAndAliasClause)->children ?? [];
|
||||
$traitSelectAndAliasClause->targetName = $interfaceNameList[0] ?? new MissingToken(TokenKind::BarToken, $this->token->fullStart);
|
||||
$traitSelectAndAliasClause->remainingTargetNames = array_slice($interfaceNameList, 1);
|
||||
} else {
|
||||
$traitSelectAndAliasClause->targetName =
|
||||
$this->parseQualifiedNameOrScopedPropertyAccessExpression($traitSelectAndAliasClause);
|
||||
$traitSelectAndAliasClause->remainingTargetNames = [];
|
||||
}
|
||||
|
||||
|
||||
// TODO errors for insteadof/as
|
||||
return $traitSelectAndAliasClause;
|
||||
};
|
||||
|
|
|
@ -90,7 +90,7 @@
|
|||
]
|
||||
}
|
||||
},
|
||||
"remainingTargetNames": null
|
||||
"remainingTargetNames": []
|
||||
}
|
||||
}
|
||||
]
|
||||
|
|
|
@ -128,7 +128,7 @@
|
|||
]
|
||||
}
|
||||
},
|
||||
"remainingTargetNames": null
|
||||
"remainingTargetNames": []
|
||||
}
|
||||
},
|
||||
{
|
||||
|
|
|
@ -95,7 +95,7 @@
|
|||
]
|
||||
}
|
||||
},
|
||||
"remainingTargetNames": null
|
||||
"remainingTargetNames": []
|
||||
}
|
||||
},
|
||||
{
|
||||
|
|
|
@ -99,7 +99,7 @@
|
|||
]
|
||||
}
|
||||
},
|
||||
"remainingTargetNames": null
|
||||
"remainingTargetNames": []
|
||||
}
|
||||
},
|
||||
{
|
||||
|
|
|
@ -96,7 +96,7 @@
|
|||
]
|
||||
}
|
||||
},
|
||||
"remainingTargetNames": null
|
||||
"remainingTargetNames": []
|
||||
}
|
||||
},
|
||||
{
|
||||
|
@ -157,7 +157,7 @@
|
|||
]
|
||||
}
|
||||
},
|
||||
"remainingTargetNames": null
|
||||
"remainingTargetNames": []
|
||||
}
|
||||
},
|
||||
{
|
||||
|
|
|
@ -149,7 +149,7 @@
|
|||
]
|
||||
}
|
||||
},
|
||||
"remainingTargetNames": null
|
||||
"remainingTargetNames": []
|
||||
}
|
||||
},
|
||||
{
|
||||
|
|
|
@ -0,0 +1,8 @@
|
|||
<?php
|
||||
// https://github.com/Microsoft/tolerant-php-parser/issues/98
|
||||
|
||||
class A {
|
||||
use X, Y, Z {
|
||||
\X::b insteadof;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,8 @@
|
|||
[
|
||||
{
|
||||
"kind": 0,
|
||||
"message": "'|' expected.",
|
||||
"start": 121,
|
||||
"length": 0
|
||||
}
|
||||
]
|
|
@ -0,0 +1,167 @@
|
|||
{
|
||||
"SourceFileNode": {
|
||||
"statementList": [
|
||||
{
|
||||
"InlineHtml": {
|
||||
"scriptSectionEndTag": null,
|
||||
"text": null,
|
||||
"scriptSectionStartTag": {
|
||||
"kind": "ScriptSectionStartTag",
|
||||
"textLength": 6
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"ClassDeclaration": {
|
||||
"abstractOrFinalModifier": null,
|
||||
"classKeyword": {
|
||||
"kind": "ClassKeyword",
|
||||
"textLength": 5
|
||||
},
|
||||
"name": {
|
||||
"kind": "Name",
|
||||
"textLength": 1
|
||||
},
|
||||
"classBaseClause": null,
|
||||
"classInterfaceClause": null,
|
||||
"classMembers": {
|
||||
"ClassMembersNode": {
|
||||
"openBrace": {
|
||||
"kind": "OpenBraceToken",
|
||||
"textLength": 1
|
||||
},
|
||||
"classMemberDeclarations": [
|
||||
{
|
||||
"TraitUseClause": {
|
||||
"useKeyword": {
|
||||
"kind": "UseKeyword",
|
||||
"textLength": 3
|
||||
},
|
||||
"traitNameList": {
|
||||
"QualifiedNameList": {
|
||||
"children": [
|
||||
{
|
||||
"QualifiedName": {
|
||||
"globalSpecifier": null,
|
||||
"relativeSpecifier": null,
|
||||
"nameParts": [
|
||||
{
|
||||
"kind": "Name",
|
||||
"textLength": 1
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"kind": "CommaToken",
|
||||
"textLength": 1
|
||||
},
|
||||
{
|
||||
"QualifiedName": {
|
||||
"globalSpecifier": null,
|
||||
"relativeSpecifier": null,
|
||||
"nameParts": [
|
||||
{
|
||||
"kind": "Name",
|
||||
"textLength": 1
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"kind": "CommaToken",
|
||||
"textLength": 1
|
||||
},
|
||||
{
|
||||
"QualifiedName": {
|
||||
"globalSpecifier": null,
|
||||
"relativeSpecifier": null,
|
||||
"nameParts": [
|
||||
{
|
||||
"kind": "Name",
|
||||
"textLength": 1
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"semicolonOrOpenBrace": {
|
||||
"kind": "OpenBraceToken",
|
||||
"textLength": 1
|
||||
},
|
||||
"traitSelectAndAliasClauses": {
|
||||
"TraitSelectOrAliasClauseList": {
|
||||
"children": [
|
||||
{
|
||||
"TraitSelectOrAliasClause": {
|
||||
"name": {
|
||||
"ScopedPropertyAccessExpression": {
|
||||
"scopeResolutionQualifier": {
|
||||
"QualifiedName": {
|
||||
"globalSpecifier": {
|
||||
"kind": "BackslashToken",
|
||||
"textLength": 1
|
||||
},
|
||||
"relativeSpecifier": null,
|
||||
"nameParts": [
|
||||
{
|
||||
"kind": "Name",
|
||||
"textLength": 1
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"doubleColon": {
|
||||
"kind": "ColonColonToken",
|
||||
"textLength": 2
|
||||
},
|
||||
"memberName": {
|
||||
"kind": "Name",
|
||||
"textLength": 1
|
||||
}
|
||||
}
|
||||
},
|
||||
"asOrInsteadOfKeyword": {
|
||||
"kind": "InsteadOfKeyword",
|
||||
"textLength": 9
|
||||
},
|
||||
"modifiers": [],
|
||||
"targetName": {
|
||||
"error": "MissingToken",
|
||||
"kind": "BarToken",
|
||||
"textLength": 0
|
||||
},
|
||||
"remainingTargetNames": []
|
||||
}
|
||||
},
|
||||
{
|
||||
"kind": "SemicolonToken",
|
||||
"textLength": 1
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"closeBrace": {
|
||||
"kind": "CloseBraceToken",
|
||||
"textLength": 1
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
"closeBrace": {
|
||||
"kind": "CloseBraceToken",
|
||||
"textLength": 1
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
"endOfFileToken": {
|
||||
"kind": "EndOfFileToken",
|
||||
"textLength": 0
|
||||
}
|
||||
}
|
||||
}
|
|
@ -90,7 +90,7 @@
|
|||
]
|
||||
}
|
||||
},
|
||||
"remainingTargetNames": null
|
||||
"remainingTargetNames": []
|
||||
}
|
||||
},
|
||||
{
|
||||
|
|
Загрузка…
Ссылка в новой задаче