Re: [PHP-DEV] Alias stdClass to DynamicObject?

2021-09-08 Thread Mike Schinkel
> On Sep 8, 2021, at 4:59 PM, Rowan Tommins wrote: >> I assume we would also disallow dynamic properties in anonymous classes too, >> right? After all, they are just statically declared classes that the >> developer do not assign a name. > > The difference I see is that stdClass/DynamicObject

Re: [PHP-DEV] Alias stdClass to DynamicObject?

2021-09-08 Thread Andreas Hennings
On Wed, 8 Sept 2021 at 23:00, Rowan Tommins wrote: > > On 08/09/2021 16:37, Mike Schinkel wrote: > > > All future code that needs to refer to the class name will still refer to > > `stdClass`, so we won't be gaining much by creating an alias. > > > Just to be clear, the only code that would need

Re: [PHP-DEV] Alias stdClass to DynamicObject?

2021-09-08 Thread Rowan Tommins
On 08/09/2021 16:37, Mike Schinkel wrote: All future code that needs to refer to the class name will still refer to `stdClass`, so we won't be gaining much by creating an alias. Just to be clear, the only code that would need to change is code that dynamically gets *out* the class name,

Re: [PHP-DEV] Alias stdClass to DynamicObject?

2021-09-08 Thread Andreas Hennings
Wow! I notice that ArrayObject already does everything we would need for json_encode(). assert(json_encode(new ArrayObject([5])) === '{"0":5}'); However, it does so in a very strange way, not using any of the public methods, but also not using dynamic properties. It seems there is a hard-coded

Re: [PHP-DEV] Alias stdClass to DynamicObject?

2021-09-08 Thread Andreas Hennings
On Wed, 8 Sept 2021 at 18:33, Lynn wrote: > > On Wed, Sep 8, 2021 at 5:38 PM Mike Schinkel wrote: > > > A couple more things; add a `JSON_OUTPUT_DYNAMIC_OBJECT` flag to output to > > DynamicObject for `json_decode()`, add a 3rd parameter for flags to > > var_export() for the same reason, a

Re: [PHP-DEV] Alias stdClass to DynamicObject?

2021-09-08 Thread Lynn
On Mon, Sep 6, 2021 at 5:28 PM Nikita Popov wrote: > What do people think about adding such an alias? Is this worthwhile? > What if `DynamicObject` becomes an interface instead of an alias? In the future `stdClass` could be deprecated and replaced by anonymous classes using the `DynamicObject`

Re: [PHP-DEV] Alias stdClass to DynamicObject?

2021-09-08 Thread Lynn
On Wed, Sep 8, 2021 at 5:38 PM Mike Schinkel wrote: > A couple more things; add a `JSON_OUTPUT_DYNAMIC_OBJECT` flag to output to > DynamicObject for `json_decode()`, add a 3rd parameter for flags to > var_export() for the same reason, a `'return_dynamic_object'` option for > `unserialize()`,

Re: [PHP-DEV] Alias stdClass to DynamicObject?

2021-09-08 Thread Mike Schinkel
> On Sep 8, 2021, at 5:44 AM, Rowan Tommins wrote: >> Is it just a special-cases that will cause as much confusion for developers >> trying to understand why there are too names for the same thing as it will >> help those who will better understand the new name > > That is certainly a risk,

Re: [PHP-DEV] Alias stdClass to DynamicObject?

2021-09-08 Thread Rowan Tommins
On 08/09/2021 11:08, Nicolas Grekas wrote: I'm reading the discussion about the side of the alias. Can't we solve these concerns by making DynamicObject extend stdClass instead of aliasing? That wouldn't allow an stdClass object to get through the DynamicObject typehint, but that shouldn't be

Re: [PHP-DEV] Alias stdClass to DynamicObject?

2021-09-08 Thread Nicolas Grekas
> 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

Re: [PHP-DEV] Alias stdClass to DynamicObject?

2021-09-08 Thread Rowan Tommins
On 08/09/2021 09:45, Mike Schinkel wrote: So I am trying to get around what this would actually mean in practice, and what the ramifications would be. The proposal is that the new name is an "alias" - the same class, but with two names. So the following would all create exactly the same

Re: [PHP-DEV] Alias stdClass to DynamicObject?

2021-09-08 Thread Mike Schinkel
> On Sep 6, 2021, at 11:28 AM, Nikita Popov 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

Re: [PHP-DEV] Alias stdClass to DynamicObject?

2021-09-08 Thread Rowan Tommins
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

Re: [PHP-DEV] Alias stdClass to DynamicObject?

2021-09-07 Thread Levi Morrison via internals
On Mon, Sep 6, 2021 at 9:29 AM Nikita Popov 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

Re: [PHP-DEV] Alias stdClass to DynamicObject?

2021-09-07 Thread Kamil Tekiela
Hi Marc, The name seems to be ok IMHO. Even though it is a class, the main use case is to denote an object that was created dynamically rather than through an instantiation of a class. And I know that a lot of usage comes from people directly creating new instances of stdClass but if you do that

Re: [PHP-DEV] Alias stdClass to DynamicObject?

2021-09-07 Thread Marc Bennewitz
On 06.09.21 17:28, Nikita Popov 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

Re: [PHP-DEV] Alias stdClass to DynamicObject?

2021-09-07 Thread Larry Garfield
On Tue, Sep 7, 2021, at 4:22 AM, Nikita Popov wrote: > On Mon, Sep 6, 2021 at 6:50 PM Kamil Tekiela wrote: > > > Hi Nikita, > > > > I think this might be a good idea, but I would like to propose yet another > > variant. > > Replace stdClass with DynamicObject and keep stdClass as an alias. It

Re: [PHP-DEV] Alias stdClass to DynamicObject?

2021-09-07 Thread Nikita Popov
On Mon, Sep 6, 2021 at 6:50 PM Kamil Tekiela wrote: > Hi Nikita, > > I think this might be a good idea, but I would like to propose yet another > variant. > Replace stdClass with DynamicObject and keep stdClass as an alias. It can > be deprecated in 8.3. > If we only add an alias, I am afraid

Re: [PHP-DEV] Alias stdClass to DynamicObject?

2021-09-06 Thread Hossein Baghayi
On Tue, 7 Sept 2021 at 01:12, Aran Reeks wrote: > ... Too much code depends on an expected type of stdClass > presently which would likely make future upgrades more difficult for no > functional gain, beyond some added clarify. What if we had the DynamicObject as a subclass of stdClass? It

Re: [PHP-DEV] Alias stdClass to DynamicObject?

2021-09-06 Thread Aran Reeks
Creating a new DynamicObject class which is the preferred alias for stdClass sounds logical but I too share the consern around making it the default anytime soon. Too much code depends on an expected type of stdClass presently which would likely make future upgrades more difficult for no

Re: [PHP-DEV] Alias stdClass to DynamicObject?

2021-09-06 Thread Björn Larsson via internals
Den 2021-09-06 kl. 18:22, skrev Christian Schneider: Am 06.09.2021 um 18:08 schrieb Benjamin Morel : Yes, please! A future where dynamic properties are only allowed on DynamicObject is bright. I have nothing against a DynamicObject alias for people who like to be more explicit in their

Re: [PHP-DEV] Alias stdClass to DynamicObject?

2021-09-06 Thread Matthew Brown
> On Sep 6, 2021, at 11:29 AM, Nikita Popov wrote: > I think this would be a massive benefit to first-time PHP users one or two years from now. I remember being confused by this terminology — I am sure bugs have been caused by people who assumed stdClass was a base class for all objects.

Re: [PHP-DEV] Alias stdClass to DynamicObject?

2021-09-06 Thread Kamil Tekiela
Hi Nikita, I think this might be a good idea, but I would like to propose yet another variant. Replace stdClass with DynamicObject and keep stdClass as an alias. It can be deprecated in 8.3. If we only add an alias, I am afraid that it will not catch on quickly enough. What I am proposing is that

Re: [PHP-DEV] Alias stdClass to DynamicObject?

2021-09-06 Thread Christian Schneider
Am 06.09.2021 um 18:08 schrieb Benjamin Morel : > Yes, please! A future where dynamic properties are only allowed on > DynamicObject is bright. I have nothing against a DynamicObject alias for people who like to be more explicit in their code... > I would even deprecate the stdClass alias

Re: [PHP-DEV] Alias stdClass to DynamicObject?

2021-09-06 Thread Benjamin Morel
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