Hi

Am 2024-11-25 17:52, schrieb Larry Garfield:
Static property asymmetric visibility was left out of the original RFC, because it seemed like it would be hard and of little use. Turns out, Ilija found a way to make it easy. (Ilija is smart.) So here's a small RFC to add aviz to static properties, because we can't think of a reason to NOT do so.

https://wiki.php.net/rfc/static-aviz

The RFC has the status “Draft” and does not appear to be linked in the overview at https://wiki.php.net/rfc. Is it intended to be open for discussion yet?

Regarding the RFC contents: I am not sure the behavior of `private(set)` implying `final` is obvious for static properties. Consider this example (https://3v4l.org/bvQjM):

    <?php

    class Foo {
        public static $baz;
    }

    class Bar extends Foo {
        public static $baz;
    }

    Foo::$baz = '2';
    Bar::$baz = '1';
    var_dump(Foo::$baz, Bar::$baz);

Non-static properties only have `$this->` for property access, but with static properties you can distinguish between `self::` and `static::`, which makes overriding a `private(set)` static property meaningful, because they are actually independent properties.

Best regards
Tim Düsterhus

Reply via email to