Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add syntactic support for asymmetric visibility #54

Merged
merged 7 commits into from
Aug 26, 2024

Conversation

thekid
Copy link
Member

@thekid thekid commented Aug 24, 2024

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 {
  public private(set) string $name= 'Test';
}
 
$person= new Person();
echo $person->name;       // OK
$person->name= 'Changed'; // Visibility error

Support in promoted constructor parameters:

class Person {
  public function __construct(private(set) string $name) { }
}

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

thekid added a commit to xp-framework/compiler that referenced this pull request Aug 24, 2024
@thekid thekid merged commit aa454ca into master Aug 26, 2024
12 checks passed
@thekid thekid deleted the feature/asymmetric-visibility branch August 26, 2024 19:27
@thekid
Copy link
Member Author

thekid commented Aug 26, 2024

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

1 participant