Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:115840 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 41812 invoked from network); 25 Aug 2021 22:03:21 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 25 Aug 2021 22:03:21 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id A02D11804AD for ; Wed, 25 Aug 2021 15:37:37 -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.7 required=5.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,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-f176.google.com (mail-qk1-f176.google.com [209.85.222.176]) (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, 25 Aug 2021 15:37:37 -0700 (PDT) Received: by mail-qk1-f176.google.com with SMTP id m21so1163215qkm.13 for ; Wed, 25 Aug 2021 15:37:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=newclarity-net.20150623.gappssmtp.com; s=20150623; h=mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=mlD1CgYAxnx3THsveqqdYO7EQWRCD02sOJGMZGhN7Og=; b=a+vKwWFSR+pewI6+S/zWSxM20sv4cmWBl2Hs+r7BiSNCP96UoSYW3neruJg8x4ESy8 dS9JdjuIH6hvpVjpT6duDH9Q0yS5eTGv2bqD23Jil9J6yu5DipS2FjalRDcaXzGp1ZaH fmChftI9vyB9ta3KvS1zOZ5b03OEYciHiX8tOvHBQwGCYzPdS7VRFGTAgut6v3FjYxpp kkeSqcRoe1UQnj+DMh/sHRI4BefgOv1gBSpwiLaXMcKdfdrLKRZr9vdpe8Z1mObWrSiH 2BmhSeGcT2YJosZ+LM7CjKYyOPSsp5bGsed4C4eMLOMXop1uJ1fIZi9lnecqbYsbKHen BcwA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=mlD1CgYAxnx3THsveqqdYO7EQWRCD02sOJGMZGhN7Og=; b=mAdYOLHhuauNWbzbkakKC+nOrt3GnLib5u7zVVXvULE5OjF+iPKZDNGS+n7W3GPBQN 4eBxFmJntIeuR0C+F3w9VBFZOmvRBRdn1M1j7gD4DUeMqdiYxWJYSjZ9YUEF0hNUROau 56V/M6FBfZ45LH+w5fLErK8+dMh2TRQkQF1K/iPkYVfVVZW6qNtD8eKQ/IvAQVeCl10k bWtw6svk1F45/wwCVc6eWk69hWshkC1MBi/9qMEjdMjCZe6O5sY3k/pW4CEni/otXrqR pJvxEPPXatBY8JMXPum1LS0AajnnuSN2UEBQ21FwmjVe46o1u2kf6aehbNZAuupfJ06I AFMg== X-Gm-Message-State: AOAM530cYTDlwfhi3g6KgfxkkUp9Uez2xSjt4XRr4Vovu7IN3sUMhvy6 PONZgPfMx3B3c/caDdZuwQ4AZLSr8MzYidSK X-Google-Smtp-Source: ABdhPJyzFYQyDClEW54WL5ML3oaoyk10NJTd4Y3o75pkg76maoQ896y08BuzdQzYldYmyZKo+dJHLg== X-Received: by 2002:a37:4141:: with SMTP id o62mr880460qka.380.1629931055591; Wed, 25 Aug 2021 15:37:35 -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 w14sm1080703qkm.81.2021.08.25.15.37.33 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 25 Aug 2021 15:37:34 -0700 (PDT) Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (Mac OS X Mail 13.4 \(3608.120.23.2.7\)) In-Reply-To: Date: Wed, 25 Aug 2021 18:37:33 -0400 Cc: PHP internals Content-Transfer-Encoding: quoted-printable Message-ID: <476A4FAA-ACEB-428C-A3E8-990464F9F98C@newclarity.net> References: <763725c0-870b-e8c4-054b-1ea0481ef877@gmail.com> To: Chase Peeler X-Mailer: Apple Mail (2.3608.120.23.2.7) Subject: Re: [PHP-DEV] [RFC] Deprecate dynamic properties From: mike@newclarity.net (Mike Schinkel) > On Aug 25, 2021, at 10:04 AM, Chase Peeler = wrote: >=20 > On Wed, Aug 25, 2021 at 9:51 AM Rowan Tommins = > wrote: >=20 >> On 25/08/2021 13:45, Nikita Popov wrote: >>=20 >>> We obviously need to keep support for dynamic properties on = stdClass, >>> and if we do so, I would expect that to apply to subclasses as well. >>=20 >> Does that actually follow, though? Right now, there is no advantage = to >> extending stdClass, so no reason to expect existing code to do so, = and >> no reason for people doing so to expect it to affect behaviour. >>=20 >>=20 >>> Second, I consider "extends stdClass" to be something of a = last-ditch >>> option. If you encounter a dynamic property deprecation warning, you >>> should generally resolve it in some other way, and only fall back to >>> "extends stdClass" as the final option. >>=20 >>=20 >> That's a reasonable argument in terms of the multiple inheritance = case. >>=20 >> My concern about the name remains though: people already do get = confused >> by the name "stdClass", because it's not in any way "standard", and >> tells you nothing about what it does. >>=20 >> Reading "class Foo extends stdClass" gives the reader no clues what >> magic behaviour is being inherited; "class Foo extends DynamicObject" >> would be much more clear. Similarly, "$foo =3D new DynamicObject; >> $foo->bar =3D 42;" is clearer than "$foo =3D new stdClass; $foo->bar = =3D 42;" >>=20 >> Regards, >>=20 >> -- >> Rowan Tommins >> [IMSoP] >>=20 >> -- >> PHP Internals - PHP Runtime Development Mailing List >> To unsubscribe, visit: https://www.php.net/unsub.php >>=20 >>=20 > Please don't do this. Call it bad coding practices or not, but this = was > something I've considered a feature of PHP and have actually built = things > around it. It's not something that can be easily refactored since it = was > part of the design. While I tend to really object to BC breakage, when I saw this proposal I = was all for it because it disallows a practice that I have seen used all = too often in cases where there was no good reason to not declare the = properties, and I know that to be fact because the cases I am referring = to are ones where I refactored to use declared properties. That said, I'd be really interested in seeing use-cases where having = dynamic properties is essential to an architecture and where it could = not be easily refactored. I cannot envision any, but I am sure that I = am just limited by the extent of my vision and so would like to know = what those use-cases would be. --------- Speaking of, it would seem like if dynamic properties were to be = deprecated PHP should also add a function that would allow registering a = callable as global hook to be called every time ANY object has a = property dynamically accessed or assigned =E2=80=94 conceptually like = how spl_autoload_register() works =E2=80=94 so that developers could run = their programs to see what properties are used. The hook could collect = class names, property names and data types to help developers who need = to update their code discover the information required for their class = declarations. Because doing it manually is a real PITA. As would be = adding __get()/__set() to every class when you have lots of classes and = you'd need to delete all that code later anyway. -Mike=