Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:116005 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 75087 invoked from network); 8 Sep 2021 08:07:46 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 8 Sep 2021 08:07:46 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 8EA73180546 for ; Wed, 8 Sep 2021 01:45:25 -0700 (PDT) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on php-smtp4.php.net X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HTML_MESSAGE,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2, SPF_HELO_NONE,SPF_NONE autolearn=no autolearn_force=no version=3.4.2 X-Spam-ASN: AS15169 209.85.128.0/17 X-Spam-Virus: No X-Envelope-From: Received: from mail-qk1-f179.google.com (mail-qk1-f179.google.com [209.85.222.179]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Wed, 8 Sep 2021 01:45:25 -0700 (PDT) Received: by mail-qk1-f179.google.com with SMTP id c10so1438183qko.11 for ; Wed, 08 Sep 2021 01:45:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=newclarity-net.20150623.gappssmtp.com; s=20150623; h=from:message-id:mime-version:subject:date:in-reply-to:cc:to :references; bh=1D291K99SZXspqZ0/+MAqrqXEYDlJI8Zp799V4z6i7c=; b=eUPtN061JqYO1Pfo1JnFM8uG+D2hiWwI9b5wUwZ1UObXtt+8AioGkngnmrjvgoFyYi I8fTFnb3W/S5Xj4rHKlFFZk6CRNp0q+t8642W/v8kE77bRVBsOO7fKkfUg+Hfhk1b3kU mqoNzvH6kdU6oB6EfJYBpTpW10Q+Vitg7CGMJ0NG+ZQdRsUYhkzY7/jWJSbg6m7/VQFn /nRs85MkJl4pnfZ1V9rLM+j1duN7VTGLtP1CTZ8TMiGg0dpIpIjlZcJGWFlzK8LNAZ36 6Ncsys3chD/ZPWfjVn+7ua6T8YIEfZ+zVCrMh2BjXoYM6bRFz1dVeq78e6epJa6jAhcR CV+A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:message-id:mime-version:subject:date :in-reply-to:cc:to:references; bh=1D291K99SZXspqZ0/+MAqrqXEYDlJI8Zp799V4z6i7c=; b=dIg1HQN/1ltRe2bQTOw3DJfzLo8ZCZMqjINixqrt+yvgDmu1c+yhS1gyzzrKi7Z3+O OMF/IK+ebZWIZq1BU4/u0lV9IUTkYrJw/idJWOqVybTuZ9KXCINUI/PALVqQ8BxC5Bqq 4SlZt/EONZWmtnr37Pubi57e1Xw0GMdoS3b4FqQdex9tS7M9x+bUaGZbdncLkxKu8npF 6dUoJ1Met7tVSNEDHHXFiRdc/BAC7VBnPwir7mzPCyILkVUAZAWto+QB/E26ivFoGeyU RWhyG7uamTWls5MluTHQRptXx2CH5xhHvykqbrxQ3wSIia/+xRVqPrtK7CcLBlLf4raG q06g== X-Gm-Message-State: AOAM530xkkKvT/qhGP1USQ1ToByIwv3fEnWKDBCdxJguWwF9RnBHyXLF lW0zS/bFz/48f1OeY2e06+NHIQ== X-Google-Smtp-Source: ABdhPJz6gzVt0h53N1QCCYq/fSQjkPD5C7ltI2HGy1nFCB+g4TRZSI/LpYlRJsZ/3njMO7Utle2dYQ== X-Received: by 2002:a05:620a:284b:: with SMTP id h11mr2217247qkp.438.1631090723620; Wed, 08 Sep 2021 01:45:23 -0700 (PDT) Received: from [192.168.1.10] (c-24-98-254-8.hsd1.ga.comcast.net. [24.98.254.8]) by smtp.gmail.com with ESMTPSA id bi20sm1196783qkb.133.2021.09.08.01.45.23 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 08 Sep 2021 01:45:23 -0700 (PDT) Message-ID: Content-Type: multipart/alternative; boundary="Apple-Mail=_A5EE723C-2E8C-4517-96C4-B2D47DDF66B4" Mime-Version: 1.0 (Mac OS X Mail 13.4 \(3608.120.23.2.7\)) Date: Wed, 8 Sep 2021 04:45:21 -0400 In-Reply-To: Cc: PHP internals To: Nikita Popov References: X-Mailer: Apple Mail (2.3608.120.23.2.7) Subject: Re: [PHP-DEV] Alias stdClass to DynamicObject? From: mike@newclarity.net (Mike Schinkel) --Apple-Mail=_A5EE723C-2E8C-4517-96C4-B2D47DDF66B4 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=utf-8 > On Sep 6, 2021, at 11:28 AM, Nikita Popov = wrote: >=20 > Hi internals, >=20 > 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. >=20 > 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). >=20 > The actual role of stdClass is to serve as a container for dynamic > properties, thus the suggested DynamicObject name. >=20 > What do people think about adding such an alias? Is this worthwhile? So I am trying to get around what this would actually mean in practice, = and what the ramifications would be. Given this proposal would `(object)array()` return an object of class = 'DynamicObject' instead of 'stdClass'? Will I be able to do a `new DynamicObject` just like I can currently do = `new stdClass`? I assume that instance would have a class of = 'DynamicObject'? And what of `new stdClass`? Would `get_class(new = stdClass)=3D=3D=3D'DynamicObject'` or would it continue to be = `get_class(new stdClass)=3D=3D=3D'stdClass'` Or would this be just like any class we can define today but that would = still support dynamic properties whereas all other classes would = disallow dynamic properties per the other proposal? What about standard library functions that return a `stdClass` object? = (I assume there has to be at least one but I am not certain there is.). = Assuming there are standard functions that return objects, will they now = return 'DynamicObject' or still 'stdClass'? =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D So while trying to get my head around the ramifications I prepared this = bit of introspection, which is still missing some applicable tests I am = sure: https://3v4l.org/MDlOn#v8.0.10 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D What I am struggling with here is to understand the vision for this = change. Not that I find the change a bad idea =E2=80=94 I do think it = intimates a good direction =E2=80=94 but at least as presented if feels = like the vision for this may not have been fleshed out, or at least not = fully communicated. Maybe what I am looking for is a vision for what this change would mean = for future PHP. 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, or is it more fully addressing the use-case for why people use = dynamic objects? =20 Maybe that's where we should start. I know there are some people who (I = think) strongly argue that we should never use non-typed objects ever = again but why do people use dynamic objects, still? This is a legitimate = question, not a rhetorical, snide or sarcastic one.=20 =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D So what are the use-cases where dynamic objects still make sense, and = just as importantly what about those use-cases is still suboptimal = besides just the class name? (I can think of a few, but want to hear = from others before I explain mine.) -Mike= --Apple-Mail=_A5EE723C-2E8C-4517-96C4-B2D47DDF66B4--