Re: Alias stdClass to DynamicObject?

From: Date: Mon, 06 Sep 2021 16:08:59 +0000
Subject: Re: Alias stdClass to DynamicObject?
References: 1  Groups: php.internals 
Request: Send a blank email to internals+get-115967@lists.php.net to get a copy of this message
Hi Nikita, Rowan, 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? Yes, please! A future where dynamic properties are only allowed on DynamicObject is bright. I would even deprecate the stdClass alias straight away, so that the whole thing can be gone in PHP 9. Kind regards, Benjamin >

« previous php.internals (#115967) next »