Merge pull request #409 from phpactor/readonly-attr
bugfix: Support attributes on readonly classes
This commit is contained in:
Коммит
4fd2db98d6
|
@ -755,7 +755,7 @@ class Parser {
|
|||
$statement = $this->parseInterfaceElementFn()($parentNode);
|
||||
} else {
|
||||
// Classlikes, anonymous functions, global functions, and arrow functions can have attributes. Global constants cannot.
|
||||
if (in_array($this->token->kind, [TokenKind::ClassKeyword, TokenKind::TraitKeyword, TokenKind::InterfaceKeyword, TokenKind::AbstractKeyword, TokenKind::FinalKeyword, TokenKind::FunctionKeyword, TokenKind::FnKeyword, TokenKind::EnumKeyword], true) ||
|
||||
if (in_array($this->token->kind, [TokenKind::ReadonlyKeyword, TokenKind::ClassKeyword, TokenKind::TraitKeyword, TokenKind::InterfaceKeyword, TokenKind::AbstractKeyword, TokenKind::FinalKeyword, TokenKind::FunctionKeyword, TokenKind::FnKeyword, TokenKind::EnumKeyword], true) ||
|
||||
$this->token->kind === TokenKind::StaticKeyword && $this->lookahead([TokenKind::FunctionKeyword, TokenKind::FnKeyword])) {
|
||||
$statement = $this->parseStatement($parentNode);
|
||||
} else {
|
||||
|
|
|
@ -0,0 +1,2 @@
|
|||
<?php
|
||||
#[Foobar]readonly class A {}
|
|
@ -0,0 +1 @@
|
|||
[]
|
|
@ -0,0 +1,91 @@
|
|||
{
|
||||
"SourceFileNode": {
|
||||
"statementList": [
|
||||
{
|
||||
"InlineHtml": {
|
||||
"scriptSectionEndTag": null,
|
||||
"text": null,
|
||||
"scriptSectionStartTag": {
|
||||
"kind": "ScriptSectionStartTag",
|
||||
"textLength": 6
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"ClassDeclaration": {
|
||||
"attributes": [
|
||||
{
|
||||
"AttributeGroup": {
|
||||
"startToken": {
|
||||
"kind": "AttributeToken",
|
||||
"textLength": 2
|
||||
},
|
||||
"attributes": {
|
||||
"AttributeElementList": {
|
||||
"children": [
|
||||
{
|
||||
"Attribute": {
|
||||
"name": {
|
||||
"QualifiedName": {
|
||||
"globalSpecifier": null,
|
||||
"relativeSpecifier": null,
|
||||
"nameParts": [
|
||||
{
|
||||
"kind": "Name",
|
||||
"textLength": 6
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"openParen": null,
|
||||
"argumentExpressionList": null,
|
||||
"closeParen": null
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"endToken": {
|
||||
"kind": "CloseBracketToken",
|
||||
"textLength": 1
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
"abstractOrFinalModifier": {
|
||||
"kind": "ReadonlyKeyword",
|
||||
"textLength": 8
|
||||
},
|
||||
"modifiers": [],
|
||||
"classKeyword": {
|
||||
"kind": "ClassKeyword",
|
||||
"textLength": 5
|
||||
},
|
||||
"name": {
|
||||
"kind": "Name",
|
||||
"textLength": 1
|
||||
},
|
||||
"classBaseClause": null,
|
||||
"classInterfaceClause": null,
|
||||
"classMembers": {
|
||||
"ClassMembersNode": {
|
||||
"openBrace": {
|
||||
"kind": "OpenBraceToken",
|
||||
"textLength": 1
|
||||
},
|
||||
"classMemberDeclarations": [],
|
||||
"closeBrace": {
|
||||
"kind": "CloseBraceToken",
|
||||
"textLength": 1
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
"endOfFileToken": {
|
||||
"kind": "EndOfFileToken",
|
||||
"textLength": 0
|
||||
}
|
||||
}
|
||||
}
|
Загрузка…
Ссылка в новой задаче