Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions src/Parser.php
Original file line number Diff line number Diff line change
Expand Up @@ -1069,6 +1069,8 @@ private function isClassMemberDeclarationStart(Token $token) {
case TokenKind::PublicKeyword:
case TokenKind::ProtectedKeyword:
case TokenKind::PrivateKeyword:
case TokenKind::ProtectedSetKeyword:
case TokenKind::PrivateSetKeyword:

// static-modifier
case TokenKind::StaticKeyword:
Expand Down Expand Up @@ -1574,6 +1576,8 @@ private function isModifier($token): bool {
case TokenKind::PublicKeyword:
case TokenKind::ProtectedKeyword:
case TokenKind::PrivateKeyword:
case TokenKind::ProtectedSetKeyword:
case TokenKind::PrivateSetKeyword:

// static-modifier
case TokenKind::StaticKeyword:
Expand All @@ -1594,6 +1598,8 @@ private function isParameterModifier($token): bool {
case TokenKind::PublicKeyword:
case TokenKind::ProtectedKeyword:
case TokenKind::PrivateKeyword:
case TokenKind::ProtectedSetKeyword:
case TokenKind::PrivateSetKeyword:

// readonly-modifier
case TokenKind::ReadonlyKeyword:
Expand Down Expand Up @@ -1648,6 +1654,8 @@ private function isParameterStartFn() {
case TokenKind::PublicKeyword:
case TokenKind::ProtectedKeyword:
case TokenKind::PrivateKeyword:
case TokenKind::ProtectedSetKeyword:
case TokenKind::PrivateSetKeyword:
case TokenKind::AttributeToken:

// dnf types (A&B)|C
Expand Down
2 changes: 2 additions & 0 deletions src/TokenStringMaps.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,9 @@ class TokenStringMaps {
"or" => TokenKind::OrKeyword,
"print" => TokenKind::PrintKeyword,
"private" => TokenKind::PrivateKeyword,
"private(set)" => TokenKind::PrivateSetKeyword,
"protected" => TokenKind::ProtectedKeyword,
"protected(set)" => TokenKind::ProtectedSetKeyword,
"public" => TokenKind::PublicKeyword,
"readonly" => TokenKind::ReadonlyKeyword,
"require" => TokenKind::RequireKeyword,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?php

class Book
{
private(set) string $title;
protected(set) string $author;
public string $bar;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[]
177 changes: 177 additions & 0 deletions tests/cases/parser84/asymetrical-visiblity-member-omit-main.php.tree
Original file line number Diff line number Diff line change
@@ -0,0 +1,177 @@
{
"SourceFileNode": {
"statementList": [
{
"InlineHtml": {
"scriptSectionEndTag": null,
"text": null,
"scriptSectionStartTag": {
"kind": "ScriptSectionStartTag",
"textLength": 6
}
}
},
{
"ClassDeclaration": {
"attributes": null,
"abstractOrFinalModifier": null,
"modifiers": [],
"classKeyword": {
"kind": "ClassKeyword",
"textLength": 5
},
"name": {
"kind": "Name",
"textLength": 4
},
"classBaseClause": null,
"classInterfaceClause": null,
"classMembers": {
"ClassMembersNode": {
"openBrace": {
"kind": "OpenBraceToken",
"textLength": 1
},
"classMemberDeclarations": [
{
"PropertyDeclaration": {
"attributes": null,
"modifiers": [
{
"kind": "PrivateSetKeyword",
"textLength": 12
}
],
"questionToken": null,
"typeDeclarationList": {
"QualifiedNameList": {
"children": [
{
"kind": "StringReservedWord",
"textLength": 6
}
]
}
},
"propertyElements": {
"ExpressionList": {
"children": [
{
"Variable": {
"dollar": null,
"name": {
"kind": "VariableName",
"textLength": 6
}
}
}
]
}
},
"propertyHooks": null,
"semicolon": {
"kind": "SemicolonToken",
"textLength": 1
}
}
},
{
"PropertyDeclaration": {
"attributes": null,
"modifiers": [
{
"kind": "ProtectedSetKeyword",
"textLength": 14
}
],
"questionToken": null,
"typeDeclarationList": {
"QualifiedNameList": {
"children": [
{
"kind": "StringReservedWord",
"textLength": 6
}
]
}
},
"propertyElements": {
"ExpressionList": {
"children": [
{
"Variable": {
"dollar": null,
"name": {
"kind": "VariableName",
"textLength": 7
}
}
}
]
}
},
"propertyHooks": null,
"semicolon": {
"kind": "SemicolonToken",
"textLength": 1
}
}
},
{
"PropertyDeclaration": {
"attributes": null,
"modifiers": [
{
"kind": "PublicKeyword",
"textLength": 6
}
],
"questionToken": null,
"typeDeclarationList": {
"QualifiedNameList": {
"children": [
{
"kind": "StringReservedWord",
"textLength": 6
}
]
}
},
"propertyElements": {
"ExpressionList": {
"children": [
{
"Variable": {
"dollar": null,
"name": {
"kind": "VariableName",
"textLength": 4
}
}
}
]
}
},
"propertyHooks": null,
"semicolon": {
"kind": "SemicolonToken",
"textLength": 1
}
}
}
],
"closeBrace": {
"kind": "CloseBraceToken",
"textLength": 1
}
}
}
}
}
],
"endOfFileToken": {
"kind": "EndOfFileToken",
"textLength": 0
}
}
}
8 changes: 8 additions & 0 deletions tests/cases/parser84/asymetrical-visiblity-member.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?php

class Book
{
public private(set) string $title;
public protected(set) string $author;
public string $bar;
}
1 change: 1 addition & 0 deletions tests/cases/parser84/asymetrical-visiblity-member.php.diag
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[]
Loading
Loading