-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Description
Description
You can define empty classes with $a = new stdClass();
.
However, I think that, not only this is a misnomer, because this std
is supposed to mean standard
and this is not really a standard class (or a base super class) but an empty class, but that we should have a shorter way to create these classes, in the same way that we can create arrays now with [ ]
.
I don't know what the best syntax might be, but what about $a = {};
?
We should also be allowed to define classes like $a = {"a" = 3}
(or something like this or maybe even be able to mimic JSON, so {"a": 1, "b": {"c": 3}}
), i.e. pre-populate the classes (if we already know some properties).
I know that this syntax may be confused with dictionaries, but then JavaScript (for example) also uses something like this.
This syntax would also be somehow consistent with JSONs and one use case of these classes is also to deal with JSONs.