Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:121709 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 26801 invoked from network); 17 Nov 2023 17:01:52 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 17 Nov 2023 17:01:52 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 78BDB18003A for ; Fri, 17 Nov 2023 09:01:52 -0800 (PST) X-Spam-Checker-Version: SpamAssassin 4.0.0 (2022-12-13) on php-smtp4.php.net X-Spam-Level: X-Spam-Status: No, score=-3.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,DMARC_PASS,FREEMAIL_FROM, HTML_MESSAGE,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE, SPF_PASS autolearn=no autolearn_force=no version=4.0.0 X-Spam-Virus: No X-Envelope-From: Received: from mail-oi1-f179.google.com (mail-oi1-f179.google.com [209.85.167.179]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Fri, 17 Nov 2023 09:01:51 -0800 (PST) Received: by mail-oi1-f179.google.com with SMTP id 5614622812f47-3b2e08526b9so413626b6e.0 for ; Fri, 17 Nov 2023 09:01:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1700240510; x=1700845310; darn=lists.php.net; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=aogqehzgSbFGvwFF+brzEM2uDk8g44OTA5MmuaifLD4=; b=Yx+wHADiOoqBz8V1U7+X/k1xpa5gm5BflcYl3t/myqGyoNju5yZ2uvBf0y3xmZArKA sQ4ZgGEvYqQAyKMiCsVI/fu0q6INyLOugqVCISK+ky6lPc1EnxyNyz/SDkOHSCn0Tpkk HWHttOkRocbLbf7T/mXe03S97kenI72bqLZwPP8VkXgm/RviRRldS/I0gRuJOfByalKv 82opgSbmah5UXgBlMWYsgw6Yx+kZoUU1zWUz3B7q7cbdtuWyUX5ALMelnXg4QAGt/hJ9 sGGsZu07mOFa0FXw7FfHZKsfHy0gksrFHJP0JzCgItTsHuviVRtDPQt9CS78UbtNYCNf L23Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1700240510; x=1700845310; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=aogqehzgSbFGvwFF+brzEM2uDk8g44OTA5MmuaifLD4=; b=JetMjWweLPmNiqhFLvyIExfPzdMcTPPLJeYyvesIxn73zAhZ/GeecBgnGZBs08Ag2U FZRkkDukkAVNgfE99a+xgoU5q194KzvZ8SkTrlXSyrhI7fcAopYpzpiSZPflZO0rJxvm mf8lj4zLDwifOtCwkR9PH46O12ztDoq+rmzcdUQer6Of5lLVG/30FmTo+pQlxpB58s4q 9Qo05IaSp4dPJUb7oqMaowKMofHdpdbYDTtTd18o+Y6Z3xI6pLqyWsPLGH24AjPtjDaG yskJwLItOioHaYZ+VKnPEBxgai3i5zWUd58WN7WWg/OxhIsXedHCItnyzBEboMN3X9Kc dtdg== X-Gm-Message-State: AOJu0Ywh2QhT6gS6vzh8o7U/DX7w3SHVFD4RT/fUFxqONnZUrOvKyGV6 KmFHxRgxWiKkwedZGalLqmn9IWsvPAUGHIgITHg= X-Google-Smtp-Source: AGHT+IGyOJCUepANL5fhlV0jrEl5WpndCEJD3/ZfTmxPbfHaFFLaWs4s856XtwH+S8Dg1T0i3OF98YruGcMR+3+XhsQ= X-Received: by 2002:a05:6358:919a:b0:16b:9823:99e1 with SMTP id j26-20020a056358919a00b0016b982399e1mr12767561rwa.3.1700240510086; Fri, 17 Nov 2023 09:01:50 -0800 (PST) MIME-Version: 1.0 References: <2b4591c1-f999-49b5-8061-67db816aa0da@gmail.com> In-Reply-To: <2b4591c1-f999-49b5-8061-67db816aa0da@gmail.com> Date: Fri, 17 Nov 2023 14:01:13 -0300 Message-ID: To: Rowan Tommins Cc: PHP Internals Content-Type: multipart/alternative; boundary="000000000000a2f23d060a5c171b" Subject: Re: [PHP-DEV] [RFC][Discussion] Harmonise "untyped" and "typed" properties From: deleugyn@gmail.com (Deleu) --000000000000a2f23d060a5c171b Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Thu, Nov 16, 2023 at 5:41=E2=80=AFPM Rowan Tommins wrote: > Hi all, > > I have finally written up an RFC I have been considering for some time: > Harmonise "untyped" and "typed" properties > > RFC URL: https://wiki.php.net/rfc/mixed_vs_untyped_properties > > > Currently, changing a property declaration from "private $foo" to > "private mixed $foo" changes its behaviour in significant ways, even > though no actual type checks are added. This RFC seeks to remove those > differences, by extending the "uninitialized" state currently reserved > for typed properties to cover all declared properties: > > * Properties without an initial value will be "uninitialized", not "null" > * Calling "unset" on a declared property will make it "uninitialized", > rather than the current complex behaviour > > > There are a handful of open questions still in the RFC, but I wanted to > present an initial draft to start the discussion, because the current > behaviour is quite hard to explain in a short e-mail. > > Please let me know your thoughts. > > Regards, > > -- > Rowan Tommins > [IMSoP] > > -- > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: https://www.php.net/unsub.php > > I have mixed feelings about this. Reading just the email gives me the impression of an unimaginable BC Break with the potential of holding back PHP upgrades A LOT. But reading the RFC, it is pretty clear that what we have now is a consequence of entropy and what is being proposed is to explicitly make a plan with all existing cases in mind. The fix for the BC is something trivial: null was implicit but now will require explicitness. The behavior which makes existing code work seems easy to get in place. However, the amount of code that would need this and the fact that Rector is not used by every PHP Developer is something that makes this a big deal. The thing I like the most about the proposal is making a sensible choice to cover the scenarios that are intertwined. Considering what has been said about opt-in making things harder with no desired mass adoption, perhaps what could be done instead is an easy-way-out (opt-out). An attribute that can be added to the class and have it automatically default untyped uninitialized properties to null. This allows the original proposal to stand and allow for a wide adoption while still giving a way-out for computer systems written 30~15 years ago that are still running and still being slowly refactored / rewritten. One thing to make it explicitly clear about my suggestion, I don't want or intend to have an attribute that keeps the current engine as-is + develop the engine with the new behavior because in my mind that could mean multiple areas of the engine and it could be quite complex to handle. My proposal is more about an ad-hoc self-contained Annotation that simply goes through the class and automatically set everything to null before the engine does its thing. In a way, it could still be a BC-break no matter what - 2 different behaviors of the language, but I'm thinking that such attribute could make things behave as-is 99% of the time and allow legacy systems to still breathe. --=20 Marco Deleu --000000000000a2f23d060a5c171b--