Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:123464 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 2B63F1A009C for ; Thu, 30 May 2024 08:36:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1717058227; bh=5g5HyKyyMkO4DOJKhgUAepT5ux+bVO4yqidVmrjGbFY=; h=References:In-Reply-To:From:Date:Subject:To:From; b=X1EpgQzG2GZw6LuKnZZSJF6OkGRG4+UeCzjHxEbe90r4tXz4sph1t5rstQddlTA7l zvcO7JmUH0oi2IetqfmV0QGmGA5sX6hEgInwyWKVPbQmoWv8GaTWFzVdAWD9t8LE8y CzdMb6Dq7Zqi2rgWyNnggSQi+9xA4Q4/2ttLe3Ulct0AV+hkKnSJAt0IjFAd1a93WS 5KqHimALpcdBrQmAuS0VIc16+ZQDRjho/SRcp9S579VgxBdXWcc6pDT1z3oihxYByU oLCrTMMM/G5CdjBNJRD8zblmCDeUGltIiw2H9B2R27/IUfay7LZlDgitdAMapTMUc6 o+9W0zB6uIrqA== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 9F8F6180003 for ; Thu, 30 May 2024 08:37:03 +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,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=4.0.0 X-Spam-Virus: Error (Cannot connect to unix socket '/var/run/clamav/clamd.ctl': connect: Connection refused) X-Envelope-From: Received: from mail-yw1-f177.google.com (mail-yw1-f177.google.com [209.85.128.177]) (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 ; Thu, 30 May 2024 08:37:02 +0000 (UTC) Received: by mail-yw1-f177.google.com with SMTP id 00721157ae682-627f46fbe14so4902437b3.2 for ; Thu, 30 May 2024 01:36:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1717058161; x=1717662961; darn=lists.php.net; h=to:subject:message-id:date:from:in-reply-to:references:mime-version :from:to:cc:subject:date:message-id:reply-to; bh=5g5HyKyyMkO4DOJKhgUAepT5ux+bVO4yqidVmrjGbFY=; b=OAU15XWLUl8pPim5o8U0q0DYHlHjeLHUD4o6u3LW5D4TqavE4TM83XXlmFYAt+OtqW VYF7zPJYY04YJLrwPhBxoF2bUjA51qcon35G5L9OvLwsJZ40S8GW91ynmrXfHd8Iduv+ HkoBIHlMkMaQdmGSit9uC1UWTHyxNJnmoJVwySlD2yo5ApRua6d4eiRs2W4Po6vpff4e 16Nl1QdDfC0fpgwegRjKB4f7XmdOS9yhEewKoS1k3F+7x5Ng5PhWukjtCjks9a1BNRrR P7qxix6mZ2DQu26fy8u9U0J23Y7TzHuohXBJ8oa+vpx3KTEp2FJfAf0RFQz3AtUrF+Ed 2UEw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1717058161; x=1717662961; h=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=5g5HyKyyMkO4DOJKhgUAepT5ux+bVO4yqidVmrjGbFY=; b=FzS12q0g6Tc4N25YLlFzu4ZFSIeQijUfeRcQoo/OxUqh5m5exWMEb22GnZnFUzfHBz pDaddf2lgLUvlwsg8FpHl07dH7i8gSesIoCCsFwo1uTaZLOg40FAdmNylWPlADgvcpCl nO0fQDupzeBJbVzoLWKyVQkwzkO7wwmkKUO4xYk9M9h75d+38c1oSmiU2AivloZVSfPb WeJ66/wYaf85BjktgKHHgQbwYghOBZE/vnPbd0hdB3vA0jxDaS6VeaZsLsRXmqdq6U0k XKdb86vgxUMY0J3wPucP4xrfb4K15oUpCacLUyrU6maJ9YYmsiwZQ24268gK5z8SjE6j XZ+A== X-Gm-Message-State: AOJu0YwKgL6yTdzXmWBP022yFiOQC9Sae1tTgkcrl6I1VIlDwIbwWa0w 7GwZ5eZ/J/U/KvykoDM7Q2mp/MXb+SnWsFTOtHNaP26nd1/kEwN3KLW5Yz0zOhNMy7nPNw1/Mve L+8GnlMPvk2I/e4J8o75M/V1HrLbEQ0F3myE= X-Google-Smtp-Source: AGHT+IEI28uRCpB9nkhwbPon4pvCdnipvHq9RvsG3x3M1S8Zx2F/chyqGl6vX9SLBsMzdvELFnq/yKDQHDOBa568OuU= X-Received: by 2002:a0d:d48b:0:b0:61b:9369:ef37 with SMTP id 00721157ae682-62c6bcc5f51mr14915347b3.46.1717058160570; Thu, 30 May 2024 01:36:00 -0700 (PDT) Precedence: bulk list-help: list-post: List-Id: internals.lists.php.net MIME-Version: 1.0 References: <0a6a61cd-f203-4dea-a7f8-97e6b885c52d@app.fastmail.com> In-Reply-To: <0a6a61cd-f203-4dea-a7f8-97e6b885c52d@app.fastmail.com> Date: Thu, 30 May 2024 11:35:42 +0300 Message-ID: Subject: Re: [PHP-DEV] [RFC] Asymmetric Visibility, v2 To: php internals Content-Type: multipart/alternative; boundary="000000000000b83c510619a7c126" From: drealecs@gmail.com (=?UTF-8?Q?Alexandru_P=C4=83tr=C4=83nescu?=) --000000000000b83c510619a7c126 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Wed, May 29, 2024 at 10:18=E2=80=AFPM Larry Garfield wrote: > As promised, Ilija and I offer this revised version of asymmetric > visibility. > > https://wiki.php.net/rfc/asymmetric-visibility-v2 > > Hey Larry, Ilija, I have one concern so far, and it's related to the inheritance section. If in a class I define the property as private, I know that there is no way for external scope or extending classes scope to read or write to the property. (of course, ignoring reading/writing using reflection or re-binded closures= ) If an extending class defines the property with a wider visibility, protected or public, it will shadow the initial one and not change its visibility. Now, if I define the property as public private(set) (or protected private(set)) with similar intentions, to make sure that there is no way for external scope or extending classes scope to write to the property, while allowing reading from external scope (or extending classes scope). But the problem is that an extending class can define the property as public protected(set) (or protected protected(set)), and that will easily allow the property that I wanted to make sure it is private for writing to be changed by an extending class to be protected. The main suggestion I can think of, is to now allow widening the write visibility when it is private. I mean, in general, to make sure it is not possible for other extending classes to access private parent class properties/methods we can use two mechanisms: - disallowing to change the visibility and making it an error - shadowing the parent property/method While shadowing works for symmetric visibility, it doesn't really work for asymmetric visibility, so disallowing seems to be a good option here. Also, maybe marking the properties as final could play a role here, not allowing private visibility for write on properties to be widened or completely not allowing it to change/redefined. Regards, Alex --000000000000b83c510619a7c126 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable

On Wed, May 29, 2024 at 10:18=E2=80=AFPM = Larry Garfield <larry@garfield= tech.com> wrote:
As promised, Ilija and I offer this revised version of asymmetric v= isibility.=C2=A0

https://wiki.php.net/rfc/asymmetric-visibility-v2



= I have one concern so far, and it's related to the inheritance section.=


If an extendin= g class defines the property with a wider visibility, protected or public, = it will shadow the initial one and not change its visibility.

Now, if I define th= e property as public private(set) (or protected private(set)) with similar = intentions,
to make sure that there is no w= ay for external scope or extending classes scope to write to the property,<= /div>
while allowing reading from external scope = (or extending classes scope).

But the problem is that an extending class can defi= ne the property as public protected(set) (or protected protected(set)),
and that will easily allow the property that I= wanted to make sure it is private for writing to be changed by an extendin= g class to be protected.


The main suggestion= I can think of, is to now allow widening the write visibility when it is p= rivate.

I mean, in general, to make sure it is not possible for other extending c= lasses to access private parent class properties/methods we can use two mec= hanisms:
- disallowing=C2=A0to change the v= isibility and making it an error
- shadowin= g the parent property/method
While shadowin= g works for symmetric=C2=A0visibility, it doesn't really work for asymm= etric=C2=A0visibility, so disallowing=C2=A0seems to be a good option here.<= br>

Al= so, maybe marking the properties as final could play a role here,
not allowing private visibility for write on propert= ies to be widened or completely not allowing it to change/redefined.
<= div class=3D"gmail_quote">

Regards,
Alex

--000000000000b83c510619a7c126--