Re: Alias stdClass to DynamicObject?
| From: | Levi Morrison via internals | Date: | Wed, 08 Sep 2021 03:02:32 +0000 |
| Subject: | Re: Alias stdClass to DynamicObject? | ||
| References: | 1 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-115999@lists.php.net to get a copy of this message | ||
On Mon, Sep 6, 2021 at 9:29 AM Nikita Popov <nikita.ppv@gmail.com> wrote:
>
> Hi internals,
>
> In the thread for deprecation of dynamic properties, Rowan suggested that
> we alias "stdClass" to "DynamicObject" in
> https://externals.io/message/115800#115802. I wanted to split
> this
> discussion off into a separate thread, as this can be decided independently.
>
> The rationale for this is that "stdClass" is something of a misnomer: The
> name makes it sound like this is a common base class, as used in a number
> of other languages. However, PHP does not have a common base class. The
> only way in which "stdClass" is "standard" is that it is the return type of
> casting an array to (object).
>
> The actual role of stdClass is to serve as a container for dynamic
> properties, thus the suggested DynamicObject name.
>
> What do people think about adding such an alias? Is this worthwhile?
>
> Regards,
> Nikita
If the alias goes to vote as the name DynamicObject, then I will
likely abstain. I don't care.
If it goes to vote under some other name, perhaps "map", or "dict",
then I would likely oppose it. I would like to keep those names
available for more useful features. There are multiple feature that
would like these names:
1. Hacklang-style dict, which is a value-based dictionary type.
Importantly, this is copy-on-write like an array; it does not have
object semantics.
2. In the event we ever add generics, it would be nice to have these
names available for interfaces.
I don't think an alias and replacement name for stdClass is important
enough to use these names.