-
Notifications
You must be signed in to change notification settings - Fork 8k
Description
Description
Please, consider this script: https://3v4l.org/bnclg#v8.4.3
As you can see, accessing a static property with object operator (->) is deprecated. If we read it, it's undefined. And if we try to write on it, a dynamic property is created (which is also deprecated).
Everything is OK if we read the same property with scope operator (::), but we can also modify it if we assign it another value. This means the static class properties are variable and we have no way to make them constant.
Indeed if we do:
class Foo
{
public static const string MY_STATIC = "foo";
}We get a Fatal error: Cannot use the static modifier on a class constant.
I wonder if this is intended for some reason or it's a missing feature. Maybe I want some properties to be available for the user without initializing the class instance, but the user can still modify them even if it would be better if they are not allowed to.