On 07/09/2021 17:15, Marc Bennewitz wrote:
* It's a class -> Why do we suffix it with "Object"?
Classes are generally named to make sense when you have an instance: a class called "HttpRequest" is not saying that the *class* is a request, but that every *instance* is one, as in "$myRequest = new HttpRequest;" Similarly, "DynamicObject" is not saying that the *class* is an object (or dynamic, for that matter), but that every instance is: "$myObject = new DynamicObject;"
* Yes it's about dynamic properties - but is this the user goal to have dynamic properties or is it an implementation detail to get something else (map/dict)?
I think a lot of uses of stdClass are precisely where people feel a map or dictionary *isn't* appropriate, and that's why they don't want to use an array: for instance, decoding a JSON string, or a database result row. The values aren't all of the same type, and you would never want to apply the same operation to all of them; you will probably initialise them once, and then access them by name, but don't have the facility to declare them up front.
Regards, -- Rowan Tommins [IMSoP] -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: https://www.php.net/unsub.php