Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:118999 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 85183 invoked from network); 13 Nov 2022 22:49:04 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 13 Nov 2022 22:49:04 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 9C3A618004D for ; Sun, 13 Nov 2022 14:49:00 -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.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,HTML_MESSAGE, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE 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-vs1-f46.google.com (mail-vs1-f46.google.com [209.85.217.46]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Sun, 13 Nov 2022 14:49:00 -0800 (PST) Received: by mail-vs1-f46.google.com with SMTP id 128so9852612vsz.12 for ; Sun, 13 Nov 2022 14:49:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=eebjoZXgWP0LQWBe8K8ClBCjIWQk2Kv+Zc/EVVAYcaQ=; b=qM6ypz8fFfLb8A3Huu39RINpJFMFphI2yt60gYzkXfFryXdTvxrGNwZFKUguv2lwf8 CisengdB5U9myWXMj2idapSgHZSLjYSr/wDsRmSzXHVlkbdyCj+xHMSDCU3F40B7BpiW U45WY2YTmF5CyRPg/EdvpflhFqwm9oIYzHVw8NQdprbNQVgqA+Tq4TCCClD7ElWqsC6v HiffAv3of7tEg2TvAUhdtVGpmdV4V1mjD4GzhgudSi01YQ66FBqqw7rPapkC+HmQO4IY McAWJE07EM2ZAUUQCCWzteHZwkgSSRO6AmN3BliH9xlvzLc04YEPV8x7san4GAjhSaj4 z50w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=eebjoZXgWP0LQWBe8K8ClBCjIWQk2Kv+Zc/EVVAYcaQ=; b=abwrfoXe5kXYkPaMTs1Ea7vOZ8waSJJd5lcMG5Fmk91ySwI4+LF0QBJzCju48NuaOZ MIJ+62kn7CZptyGNaOkZjfFUfru0ztEYO8aX5HE3hCXEAdrD3tl8Ex2a7OcAP/kVFISu K/4STxc2DuVveyviUeOSA/iNLYwiyJVhGAugaG9UgYARh4K0B8IYV8T4O3xFb1HvSsx0 UScop+d99L93iE75h5UiP85Fn8e7tviExlCvbC2qlFokGCa141xyyE+thVDtatdHcNoM F8xmF9VVSQO4TDngEtICh8sZezBes7Fv7peE7XuoDhweYsiLLcoOU1o9fgX6fBTJ3H+z vr0g== X-Gm-Message-State: ANoB5pmEoLVl2LBuzBY9lQG+Q65tPOQ25VkEm4tmh3jwSRlm2wBEfTs1 ml31l7SO3qM7tAif172hSr5wonk2QqHFSgfN4hc= X-Google-Smtp-Source: AA0mqf56/S4t0qLf8YPCuVOpAbTNoP9lCk5Qw7v8FzWABByS+S3Ugr//mBaA+NjYLM5t3d9sbVdma3HIhBohgZUGMYU= X-Received: by 2002:a05:6102:c4f:b0:3a7:c762:9209 with SMTP id y15-20020a0561020c4f00b003a7c7629209mr4481739vss.1.1668379739193; Sun, 13 Nov 2022 14:48:59 -0800 (PST) MIME-Version: 1.0 References: <0854b030-c51c-4c1b-a7dd-22835a1e5da9@app.fastmail.com> In-Reply-To: <0854b030-c51c-4c1b-a7dd-22835a1e5da9@app.fastmail.com> Date: Sun, 13 Nov 2022 19:48:22 -0300 Message-ID: To: Larry Garfield Cc: php internals Content-Type: multipart/alternative; boundary="000000000000b486d405ed61ed23" Subject: Re: [PHP-DEV] [RFC] Asymmetric Visibility, with readonly From: deleugyn@gmail.com (Deleu) --000000000000b486d405ed61ed23 Content-Type: text/plain; charset="UTF-8" On Sun, Nov 13, 2022 at 5:09 PM Larry Garfield wrote: > Hi folks. Ilija is nearly done with the implementation for asymmetric > visibility and flushing out edge cases, but we've run into one design > question we'd like feedback on. > > There's two design decisions we've made at this point, both of which we > think are logical and reasonable: > > 1. If specified, the set visibility must be tighter than the get > visibility. So `protected protected(set)` and `protected public(set)` are > not permitted, for instance. > > 2. `readonly` is a "write once" flag that may be combined with asymmetric > visibility. If no set visibility is specified, `readoly` implies > `private(set)`, but a different set visibility may also be provided. > These are both reasonable rules. However, it creates a conflict. > Specifically, in the following cases: > To unsubscribe, visit: https://www.php.net/unsub.php > > The more I think about this, the more it makes more sense (to me) to simplify it even further; 1) The set visibility should be the same as the get visibility when one is not provided. That is: ``` public $var -> public public(set) $var protected $var -> protected protected(set) $var private $var -> private private(set) $var ``` The explicit declaration of same visibility can be disallowed e.g. `public public(set) $var` is not allowed, you must use `public $var` if you want visibility symmetry. However, if it simplifies implementation to allow it, why not? The behavior would already be in place anyway. 2) The readonly flag should no longer have an impact on the set visibility. This is again a conceptual breaking change, but one that can even be fixed with a SEARCH/REPLACE on a project scope. The "breaking change" is categorized as follows: The code `public readonly $var` used to be `public private(set) readonly $var` should become `public public(set) readonly $var` The code `protected readonly $var` used to be `protected private(set) readonly $var` should become `protected protected(set) readonly $var` The code `private readonly $var` should not have any change. -- Marco Deleu --000000000000b486d405ed61ed23--