Skip to content

Add syntactic support for asymmetric visibility - #54

Merged
thekid merged 7 commits into
masterfrom
feature/asymmetric-visibility
Aug 26, 2024
Merged

Add syntactic support for asymmetric visibility#54
thekid merged 7 commits into
masterfrom
feature/asymmetric-visibility

Conversation

@thekid

@thekidthekid commented Aug 24, 2024

Copy link
Copy Markdown
Member

This pull request adds syntactic support for asymmetric visibility using (set) specifiers on property modifiers. The modifiers contain the string as declared, e.g. "private(set)" in the below example and need to be translated by the compiler!

Example

Support in property declarations:

class Person {
publicprivate(set)string$name= 'Test';
}
$person= newPerson();
echo$person->name; // OK$person->name= 'Changed'; // Visibility error

Support in promoted constructor parameters:

class Person {
publicfunction__construct(private(set)string$name) { }
}

See https://wiki.php.net/rfc/asymmetric-visibility-v2 and xp-framework/compiler#182

Comment threadsrc/main/php/lang/ast/syntax/PHP.class.php
Comment threadsrc/main/php/lang/ast/syntax/PHP.class.php Outdated
thekid added a commit to xp-framework/compiler that referenced this pull request Aug 24, 2024
@thekid
thekid merged commit aa454ca into masterAug 26, 2024
@thekid
thekid deleted the feature/asymmetric-visibility branch August 26, 2024 19:27
@thekid

Copy link
Copy Markdown
MemberAuthor

Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

1 participant

@thekid