Newsgroups: php.internals
Path: news.php.net
Xref: news.php.net php.internals:124607
X-Original-To: internals@lists.php.net
Delivered-To: internals@lists.php.net
Received: from php-smtp4.php.net (php-smtp4.php.net [45.112.84.5])
	by qa.php.net (Postfix) with ESMTPS id 8DC1E1A00B7
	for <internals@lists.php.net>; Fri, 26 Jul 2024 11:37:00 +0000 (UTC)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail;
	t=1721993915; bh=cBQyIiWc4OvQOZm47bbJDUb8F8WhmzGL0TJhBlYP3PM=;
	h=Date:Subject:To:References:From:In-Reply-To:From;
	b=KrDxqwgDpUYgiWKr4xNIpKh9UncEL7BKoAWf1CNEsXKBDs5e6yDrxuQJ/tZkFv+Y0
	 fTyBBlFwaAKbtqrHxw80pEQCcDkNuvSeS/cAZq3KDkFmh00/HcG6ZZ8flqlNznZFyn
	 T1F5pa3OU5m3XEKQiMtEA7fNkVGs5kHnAaP/tviEUmj4f9R3g9zaomNEEf8TMnhXn1
	 eiSvWA8QqE1lulI1N9foKYB9DgU9RKQ8ixkFfXwdZwY65TTilvn0frDP5ZkoeTGaR4
	 evLLcfIwOxnYAkj08dS/mmwODA/Pw/oyf2RfJpWxh2pE7+P01ZDIDcGQxUNIyqguJd
	 g7V+rO5mkyVzg==
Received: from php-smtp4.php.net (localhost [127.0.0.1])
	by php-smtp4.php.net (Postfix) with ESMTP id 7F2F718005D
	for <internals@lists.php.net>; Fri, 26 Jul 2024 11:38:34 +0000 (UTC)
X-Spam-Checker-Version: SpamAssassin 4.0.0 (2022-12-13) on php-smtp4.php.net
X-Spam-Level: 
X-Spam-Status: No, score=0.6 required=5.0 tests=BAYES_50,DKIM_SIGNED,
	DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,DMARC_PASS,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: <j.boggiano@seld.be>
Received: from mail-wr1-f46.google.com (mail-wr1-f46.google.com [209.85.221.46])
	(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 <internals@lists.php.net>; Fri, 26 Jul 2024 11:38:34 +0000 (UTC)
Received: by mail-wr1-f46.google.com with SMTP id ffacd0b85a97d-368440b073bso1233233f8f.0
        for <internals@lists.php.net>; Fri, 26 Jul 2024 04:36:58 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=seld.be; s=google; t=1721993817; x=1722598617; darn=lists.php.net;
        h=in-reply-to:from:content-language:references:to:subject:user-agent
         :mime-version:date:message-id:from:to:cc:subject:date:message-id
         :reply-to;
        bh=kxgjkNQBJoPIqxMQpdNwyHZW7527Hj3Ru55tj4m7Tx4=;
        b=cwCmmCi8T9dR1c3ecaLg721yas6gR8l0V7JeQr4d3SnCbBPbDTrhfcphjsWdsZhwYk
         K/riwA9kLu5TgkKhtDoAVYEIddDQBJuV+04NH3Yyh+lKpW2n3EeOD9l7ZhCQHSgpqgkO
         4g0kLLgmwT2aBPwmyU8A8XKxWkwARLri5cSg31k1S2QGn7LtLQN6dHVTjNs2UstjbNxr
         9YDkLQeEdYvbwJ16YGxewbp7gWrb8b/tZ3vq4dT+8+daSnMuEcU3Bs9CekIlee1qmEuA
         UmuqU/qfX2NQW7uG60IdQR6KPpLR148avjRKNktTiTflNFhm1Zdl03x4f+bUZLPn9pBy
         e5Pg==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20230601; t=1721993817; x=1722598617;
        h=in-reply-to:from:content-language:references:to:subject:user-agent
         :mime-version:date:message-id:x-gm-message-state:from:to:cc:subject
         :date:message-id:reply-to;
        bh=kxgjkNQBJoPIqxMQpdNwyHZW7527Hj3Ru55tj4m7Tx4=;
        b=b60swxRZuwOD+0itSpjV/PE7p3NT+PsUArWdsdCKEqneagn4eELRzbYoYo5GGwcQDw
         +BX/xoKr6VKdAPemgQr/u2JOWDd5+4g3aLa4U/z08dij9B4zyvGk3CE1I1C1e4ZUnYrH
         5bnjozRd5msfhpCgf5ZHEptCPxP1G+TO7NPmD+jRIaPAlBLNPhGYBALAwk6BIGooGPYh
         Tmp8dETNolvyFzDLkeIdFcBheNBC2/olvQTs+HiHXzizsfo/ZObf0wJUd+SPZZ2IL4id
         +InP+wJ/vGaxXCrJ1NEK055GN7d7SVtDyVtfO2meEtGy6DEG9tKACCKmUXzIcNaS9Z0l
         dL9A==
X-Forwarded-Encrypted: i=1; AJvYcCUDJX22wLRPn0quzBngWW6amyypej4EIKNtlLXEH9nzBSWYndmxRdsxkMZxRCp0Pk7dXqScie2g3lyDg0jhPp2ZLLYVapKl7Q==
X-Gm-Message-State: AOJu0Ywr52r+HzGbsgSqD/0jtswukS99QRnDu1IJFxEpnVYBgsyrnKvA
	P7Vz+V7Vw/RLQ19TswhewFGb5wFAN57B4000+DEe7GOuEoDJ0tr8BeNnj8Zgy5+QynjNKG9who5
	Dg1w=
X-Google-Smtp-Source: AGHT+IGhHW7nnWOYUJQUhitHSowpPnR6ptOUf+ueUGTISFM/nbxZvbFiP4OCE03hsUtASQywYwHpIQ==
X-Received: by 2002:a5d:5743:0:b0:362:4679:b5a with SMTP id ffacd0b85a97d-369f66bbfb7mr5565395f8f.16.1721993817123;
        Fri, 26 Jul 2024 04:36:57 -0700 (PDT)
Received: from ?IPV6:2a02:168:4b6e:0:c895:7592:a064:25f2? ([2a02:168:4b6e:0:c895:7592:a064:25f2])
        by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-36b367d939esm4893394f8f.25.2024.07.26.04.36.56
        (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128);
        Fri, 26 Jul 2024 04:36:56 -0700 (PDT)
Content-Type: multipart/alternative;
 boundary="------------kxWL71HFU14BAlW669vrekOD"
Message-ID: <4e7714cb-0d88-43f5-aa30-9adb799e0b28@seld.be>
Date: Fri, 26 Jul 2024 13:36:55 +0200
Precedence: bulk
list-help: <mailto:internals+help@lists.php.net
list-unsubscribe: <mailto:internals+unsubscribe@lists.php.net>
list-post: <mailto:internals@lists.php.net>
List-Id: internals.lists.php.net
x-ms-reactions: disallow
MIME-Version: 1.0
User-Agent: Mozilla Thunderbird
Subject: Re: [PHP-DEV] [RFC] Asymmetric Visibility, v2
To: Rob Landers <rob@bottled.codes>, internals@lists.php.net
References: <0a6a61cd-f203-4dea-a7f8-97e6b885c52d@app.fastmail.com>
 <b5c0be62-ea39-47fb-a8f8-ab6cd5ee3dab@app.fastmail.com>
 <CP8P284MB2148CB72E1A6A7AB5F29E8F093AE2@CP8P284MB2148.BRAP284.PROD.OUTLOOK.COM>
 <a3154cde-73ca-4b8e-bf90-b9aeabd5fbce@app.fastmail.com>
 <66c4ac1c-b3d7-4b20-b986-1fe1a464f485@app.fastmail.com>
Content-Language: fr
In-Reply-To: <66c4ac1c-b3d7-4b20-b986-1fe1a464f485@app.fastmail.com>
From: j.boggiano@seld.be (Jordi Boggiano)

This is a multi-part message in MIME format.
--------------kxWL71HFU14BAlW669vrekOD
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit

On 21.07.2024 11:21, Rob Landers wrote:
>
> On Sat, Jul 20, 2024, at 23:51, Larry Garfield wrote:
>> On Sat, Jul 20, 2024, at 7:22 AM, Rodrigo Vieira wrote:
>> > Will the alternative syntax on hook not even be put to a vote?
>>
>> It was, a year and a half ago when Aviz was first proposed.  The 
>> preference was split, but leaned toward the prefix-style syntax.  So 
>> we went with that.  I don't think we'll ever get everyone to want the 
>> same syntax, but we're using the one that was both somewhat more 
>> popular, and (as discussed in the RFC) arguably superior.
>>
>> As the "comments in yield from" thread has shown, *any* even slight 
>> change to PHP's syntax will require work from static analysis tools.  
>> That's the nature of the problem space, regardless of the syntax 
>> specifics.
>>
>> --Larry Garfield
>>
>
> Just to play devil’s advocate, it was also before we had property 
> hooks who advertised itself as a way to “wrap and guard access to 
> object properties” but we are simply ignoring their existence here.
>
Just to compare them, because my initial gut feel was to say "yes please 
just put this together with hooks"..

As far as I understand these would be the two options?

      class C {
          public protected(set) $answer { get => 42; set => { $this->answer = $value * 2; }
          public private(set) $publicReadOnly;
      }


      class C {
          public $answer { get => 42; protected set => { $this->answer = $value * 2; }
          public $publicReadOnly { private set; }
      }

And now that I see it spelled out more, I do agree that while it appears a bit more verbose, and this "(set)" looks odd at first, having all the visibility upfront is a lot clearer than having to read through the hooks to see what visibility applies.

Best,
Jordi

-- 
Jordi Boggiano
@seldaek -https://seld.be

--------------kxWL71HFU14BAlW669vrekOD
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: 8bit

<!DOCTYPE html>
<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  </head>
  <body>
    <div class="moz-cite-prefix">On 21.07.2024 11:21, Rob Landers wrote:<br>
    </div>
    <blockquote type="cite"
      cite="mid:66c4ac1c-b3d7-4b20-b986-1fe1a464f485@app.fastmail.com">
      <meta http-equiv="content-type" content="text/html; charset=UTF-8">
      <title></title>
      <style type="text/css">p.MsoNormal,p.MsoNoSpacing{margin:0}</style>
      <div><br>
      </div>
      <div>On Sat, Jul 20, 2024, at 23:51, Larry Garfield wrote:<br>
      </div>
      <blockquote type="cite" id="qt" style="">
        <div>On Sat, Jul 20, 2024, at 7:22 AM, Rodrigo Vieira wrote:<br>
        </div>
        <div>&gt; Will the alternative syntax on hook not even be put to
          a vote?<br>
        </div>
        <div><br>
        </div>
        <div>It was, a year and a half ago when Aviz was first
          proposed.  The preference was split, but leaned toward the
          prefix-style syntax.  So we went with that.  I don't think
          we'll ever get everyone to want the same syntax, but we're
          using the one that was both somewhat more popular, and (as
          discussed in the RFC) arguably superior.<br>
        </div>
        <div><br>
        </div>
        <div>As the "comments in yield from" thread has shown, *any*
          even slight change to PHP's syntax will require work from
          static analysis tools.  That's the nature of the problem
          space, regardless of the syntax specifics.<br>
        </div>
        <div><br>
        </div>
        <div>--Larry Garfield<br>
        </div>
        <div><br>
        </div>
      </blockquote>
      <div><br>
      </div>
      <div>Just to play devil’s advocate, it was also before we had
        property hooks who advertised itself as a way to “wrap and guard
        access to object properties” but we are simply ignoring their
        existence here.<br>
      </div>
      <div><br>
      </div>
    </blockquote>
    <p>Just to compare them, because my initial gut feel was to say "yes
      please just put this together with hooks"..<br>
    </p>
    <p>As far as I understand these would be the two options?<br>
    </p>
    <pre class="moz-quote-pre" wrap="">     class C {
         public protected(set) $answer { get =&gt; 42; set =&gt; { $this-&gt;answer = $value * 2; }
         public private(set) $publicReadOnly;
     }


     class C {
         public $answer { get =&gt; 42; protected set =&gt; { $this-&gt;answer = $value * 2; }
         public $publicReadOnly { private set; }
     }

And now that I see it spelled out more, I do agree that while it appears a bit more verbose, and this "(set)" looks odd at first, having all the visibility upfront is a lot clearer than having to read through the hooks to see what visibility applies.

Best,
Jordi
</pre>
    <p></p>
    <pre class="moz-signature" cols="72">-- 
Jordi Boggiano
@seldaek - <a class="moz-txt-link-freetext" href="https://seld.be">https://seld.be</a></pre>
  </body>
</html>

--------------kxWL71HFU14BAlW669vrekOD--