Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:116516 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 14309 invoked from network); 25 Nov 2021 20:01:22 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 25 Nov 2021 20:01:22 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id B60401804B5 for ; Thu, 25 Nov 2021 12:58:38 -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=-0.5 required=5.0 tests=BAYES_05,DKIM_SIGNED, DKIM_VALID,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-ua1-f53.google.com (mail-ua1-f53.google.com [209.85.222.53]) (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 ; Thu, 25 Nov 2021 12:58:37 -0800 (PST) Received: by mail-ua1-f53.google.com with SMTP id az37so14668456uab.13 for ; Thu, 25 Nov 2021 12:58:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=basereality-com.20210112.gappssmtp.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=Qg9lwEqezXWm4jP6vUiWC+rYIyx9Bu2EcFZUssrdV8Q=; b=CaYh8+QaGzm1Vc1AduWIph2o5egOhvIlgocX3ERsdaBuSghaOp6PmcHE/9qyw2l3Rg lo0y7SnWFGheE7nW0ni86sOIXGA6X85NKykzEYPMryp+czmAPUR8fWyAjHmahZbOnZr+ EumhlWsSclHxVdtqBgTRLhaHEh5ID/w4+zi8j7xp9Ou842SpAVqQn6WKFrKBbbZfEj+z g4UsD54+qimIyl6R0rSh7wVjCAPBo0gO5+Kr3FbYhV5uPi5ihz2ZlCqAsxZTpGyJBrqv 1j9mMxGWNmhN3cCXNQ1nlp0l462tkw6srMdsK/OqgSNEkeF/HL1RRncvR4oxJJ0Tjcup ESsA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=Qg9lwEqezXWm4jP6vUiWC+rYIyx9Bu2EcFZUssrdV8Q=; b=i28kJr6zwG0+HMT/1o3Ap6q9vtUzLcXaovDtHwe2HRW9hg0fyOl/7yO866nRmnpuoe jOl1/1XeMqlv5u7cBYQEGdknGckv8/VoRG8M5BoM438jzmylXXFKpLLjbhQsI99dH5/5 uYBQT8h4UUuMv90MvKRn7wft/CekJxZb5Xl9VxJzaURYOhXpwOdG7gGVgkBFrBjh3TSI TxeUumFuiZguQBqVBC4myB2AJv8d41jpbF070d7IkPMLioZ/W5iai/azDD5BLNxtXxKR VjlZtWb/00d2HAFeQklZUBsRfWwCpl+ugNx97euuWIh4WPD+DLuPNHStDpMT8orRtL85 1G7w== X-Gm-Message-State: AOAM533/cg0Ptk7PmYr/QKFUw2/J+PUuJA2QD7a/ekzygoZ6Fo4gT8Xo k0DGlUcU+hMIT6gGLTOwCKBEcGDfmZfXWsHVxFqvaB4irdXXMkD6 X-Google-Smtp-Source: ABdhPJxlNzdfLFzVffZz3peaeq638NRGXW5/+ptOygCLdVpLNduayh9L1tgSkTNdK7/cTEdVfPXOldeRaQU02JNuL5s= X-Received: by 2002:a05:6102:374c:: with SMTP id u12mr13957773vst.29.1637873917168; Thu, 25 Nov 2021 12:58:37 -0800 (PST) MIME-Version: 1.0 References: In-Reply-To: Date: Thu, 25 Nov 2021 20:58:26 +0000 Message-ID: To: "Matthew Weier O'Phinney" Cc: PHP internals , Andreas Heigl Content-Type: text/plain; charset="UTF-8" Subject: Re: [PHP-DEV] [VOTE] Deprecate dynamic properties From: Danack@basereality.com (Dan Ackroyd) On Fri, 12 Nov 2021 at 19:00, Matthew Weier O'Phinney wrote: > > Our IDEs, coding standards, and static analysis tools can already flag > these things for us, helping us catch them early. Hell, unit testing will > find these for us, when a test fails due to a value not being set in a > property that we expected. New users don't have these tools. And a lot of 'experienced' developers don't have those tools either. A disconcerting number of developers don't even use source control. Although exactly which users a language should be designed to cater for, I don't think an answer of "those who have used it long enough to setup static analysis tools" is a great one. But even when people have static analysis tools setup, they are slow to run. Andreas Heigl wrote: > So while the static analysis is one possibility, the other > one is writing appropriate tests. > ..... > So the mistakes-part would be easy to handle. This is not my experience. My experience is the same as Matthew Brown wrote: > I have heard newcomers express literal > surprise when discovering this for the first time, and not in a delighted > way. People encounter the 'feature' of PHP not warning or erroring on dynamically creating a property by accident most of the time. They make a typo in their code and wonder why their code isn't working as expected. Even though I use an IDE, and have pretty comprehensive static analysis and tests, this feature keeps biting me often enough that I created a trait to stop it (https://github.com/Danack/Params/blob/main/lib/Params/SafeAccess.php) which I normally copy and paste into each project. Matthew Weier O'Phinney wrote: > Making this fundamental change to the language means, however, that a lot > of things that we were previously able to do that "just worked" now raise a > deprecation notice, and, later, a compilation error... unless we make a > change to our already working, fully functional code. This is the trade-off that all RFCs that have BC breaks have: 1. it's going to cause some work for projects that deliberately use this feature. 2. it's going to save time/improve the developer experience for people in the future If PHP was a dead language that fewer people are starting to learn, and few new projects are started using it, then option 1 is probably the side to prioritise. But I'm hoping that PHP isn't a dead language, and that the future benefit from not having to spend so long debugging their code is greater than a small amount of BC break. For the people who are currently voting 'no', I'd ask are you really sure that the amount of work adding "#[AllowDynamicProperties]" to the classes you want to keep having dynamic properties is really that much time compared to the time that would be saved by having PHP itself give an error when a user accidentally creates a dynamic property? cheers Dan Ack