Home
New in PHP 8.5: Asymmetric Visibility for Static Properties
Liked 8 times

A small but meaningful update in PHP 8.5 introduces asymmetric visibility for static properties.

This minor addition brings asymmetric visibility—already available for instance properties—to static properties as well.

Previously, this was valid syntax:

 final class PublicPrivateSetClass {
    public private(set) string $instanceProperty;
} 

As of PHP 8.5, you can now do the same with static properties:

 final class PublicPrivateSetClass {
    public private(set) static string $staticProperty;
} 

While not the most groundbreaking feature, it improves consistency in the language—which is always a welcome change.


More from New in PHP 8.5:


Tip: To comment on or like this post, open it on your favourite Fediverse instance (such as Mastodon or Lemmy).
© 2024 Dominik Chrástecký. All rights reserved.