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

8.4 - Asymmetric Visibility #1144

Open
4 tasks
genintho opened this issue Dec 2, 2024 · 0 comments
Open
4 tasks

8.4 - Asymmetric Visibility #1144

genintho opened this issue Dec 2, 2024 · 0 comments

Comments

@genintho
Copy link
Collaborator

genintho commented Dec 2, 2024

RFC - https://wiki.php.net/rfc/asymmetric-visibility-v2

  • classic
class Foo
{
    public private(set) string $bar = 'baz';
}
  • property promotion
class Foo
{
    public function __construct(
        public private(set) string $bar,
    ) {}
}
  • abbreviated form
public private(set) string $foo;
private(set) string $foo;
 
public protected(set) string $foo;
protected(set) string $foo;
  • relation with readonly
// These create a public-read, protected-write, write-once property.
public protected(set) readonly string $foo;
public readonly string $foo;
readonly string $foo;
 
// These creates a public-read, private-set, write-once, final property.
public private(set) readonly string $foo;
private(set) readonly string $foo;
 
// These create a public-read, public-write, write-once property.
// While use cases for this configuration are likely few, 
// there's no intrinsic reason it should be forbidden.
public public(set) readonly string $foo;
public(set) readonly string $foo;
 
// These create a private-read, private-write, write-once, final property.
private private(set) readonly string $foo;
private readonly string $foo;
 
// These create a protected-read, protected-write, write-once property.
protected protected(set) readonly string $foo;
protected readonly string $foo;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant