Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:116382 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 7812 invoked from network); 15 Nov 2021 16:26:46 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 15 Nov 2021 16:26:46 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id D33DB18053F for ; Mon, 15 Nov 2021 09:21:30 -0800 (PST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on php-smtp4.php.net X-Spam-Level: X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_LOW,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_NONE autolearn=no autolearn_force=no version=3.4.2 X-Spam-ASN: AS11403 64.147.123.0/24 X-Spam-Virus: No X-Envelope-From: Received: from wout4-smtp.messagingengine.com (wout4-smtp.messagingengine.com [64.147.123.20]) (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 ; Mon, 15 Nov 2021 09:21:30 -0800 (PST) Received: from compute6.internal (compute6.nyi.internal [10.202.2.46]) by mailout.west.internal (Postfix) with ESMTP id 1EB8C3201D7C for ; Mon, 15 Nov 2021 12:21:29 -0500 (EST) Received: from imap43 ([10.202.2.93]) by compute6.internal (MEProxy); Mon, 15 Nov 2021 12:21:29 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to:x-me-proxy :x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm1; bh=gIUoa8 G3qJTovuL8UJPq+jTy/F82UfY7i03JoK1S3jw=; b=mfTTmflahIyEjoPA5vZIBk j5nPSDIsGkmiL4y8rF7nvSF8Wk/kHEZGxmXUHPIOkOxh65bmVNIjhGvYDr67SAEf JrdcKJR5/SndTaRHgFAJxl9FtjfV6E4Hj2Q8g/INxuMl/GHDkyJvDZj98cqn8tqV 0yC32IRuqc60Xa2b7Ze8w++r+fthS9hsQjHe000L+4TL2srmPCuL/WbLMzqIwDCT RCnFN3QXNAEKjaK86zyDAbEb6pNKg9xrbP7tsJBF3HBsVGfuRdE0OYYwnGJr+XoX HgNzaajHG8QZ2vQKbQV6pInBtOE0iNrBeDlFKAnM1pYPSWLAZaV29zupby+4Lx7w == X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvuddrfedtgdejvdcutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpefofgggkfgjfhffhffvufgtsehttdertderredtnecuhfhrohhmpedfnfgrrhhr hicuifgrrhhfihgvlhgufdcuoehlrghrrhihsehgrghrfhhivghlughtvggthhdrtghomh eqnecuggftrfgrthhtvghrnhepgeelgfekudeivddvteffueejffdthfejieevhefgffek udevkedtvdelvddvffefnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrg hilhhfrhhomheplhgrrhhrhiesghgrrhhfihgvlhguthgvtghhrdgtohhm X-ME-Proxy: Received: by mailuser.nyi.internal (Postfix, from userid 501) id 9CE4FAC0E8C; Mon, 15 Nov 2021 12:21:28 -0500 (EST) X-Mailer: MessagingEngine.com Webmail Interface User-Agent: Cyrus-JMAP/3.5.0-alpha0-1371-g2296cc3491-fm-20211109.003-g2296cc34 Mime-Version: 1.0 Message-ID: In-Reply-To: References: <371ca983-2b07-ae39-3629-49cf7ff8ee64@heigl.org> <497ab532-a39d-389c-8bca-86768650c2f4@heigl.org> Date: Mon, 15 Nov 2021 11:20:40 -0600 To: "php internals" Content-Type: text/plain Subject: Re: [PHP-DEV] Re: [RFC] Deprecate dynamic properties From: larry@garfieldtech.com ("Larry Garfield") On Mon, Nov 15, 2021, at 10:52 AM, Rowan Tommins wrote: > On 15/11/2021 16:23, Andreas Heigl wrote: >> One thing, that can verify the correct working of properties, whether >> that is dynamic or static ones, is testing. > > > Can it? I can't actually see how that would work, without also having a > way to detect when dynamic properties were accessed, which brings us > full circle. Also: > > >> So the mistakes-part would be easy to handle. > > If you are working with a million lines of code going back 20 years, > "write tests for everything" is not "easy to handle"; it's a long-term > ambition which you chip away at when priorities allow. > > "Logging all deprecations and warnings on a production workload", > however, *is* easy to handle. Diagnostic messages in logs are the *only* > way this behaviour will be spotted in old code. > > >> What I am still missing is the differentiation between "everything is >> strict and you have to explicitly opt-in to make it dynamic" and an >> "everything is dynamic and you can use a marker to mark this >> explicitly an intended behaviour". That would allow users to mark a >> class explicitly to use dynamic features even though it would make no >> difference code-wise. > > > I'm not sure what you mean by that. Do you mean, create the attribute, > but don't actually do anything with it? Would the plan be to deprecate > later? Never remove at all? A possible idea to help make this transition (which I do support) more gradual: Instead of an "allow" attribute, introduce a boolean flag attribute. #[DynamicProperties(true)] class Beep {} The attribute marks whether dynamic properties are enabled or disabled via boolean. If disabled, then they're an error if used. 8.2: Introduce the attribute, with a default of TRUE. Exactly zero code breaks, but people can start adding the attribute now. That means people who want to lock-out dynamic properties can do so starting now, and those cases that do need them (or can't easily get away from them) can be flagged far in advance. 8.something: Change the default to FALSE. Using dynamic properties when false throws a deprecation, not an error. People have had some number of years to add the attribute either direction if desired. 9.0: Change the deprecation to an error, if the attribute is set false (which by now is the default) and dynamic properties are used. Sometime in the future: Setting the attribute to true triggers a deprecation. Sometime in the future: Remove dynamic properties entirely, and the attribute along with it. People can use __get/__set if they really need. This still gets us to the same place in the end, but introduces another stage along the way to make the transition more gradual. We can debate which version the default should flip in, I don't much mind. That could even wait for 9 if we want to be really really gradual about it. Meanwhile, IDEs and code templates can start including the attribute set to false by default on any new classes that get written, just like they have done for years with strict types. Nikita, would that be feasible? Matthew, Derick, would that be satisfactory? --Larry Garfield