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.

  • SomeRandomNoob@discuss.tchncs.de
    link
    fedilink
    arrow-up
    0
    ·
    8 days ago

    I like this feature (for both static and non-static properties). It just reads kinda cringe with both the “public” and “private” keywords for the same property.