Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:123468 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 9C8991A009C for ; Fri, 31 May 2024 07:30:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1717140664; bh=uvw01RyTOsrIcrWDrMqB6EfsrC/42zHFgr5oX9x1KvA=; h=From:Subject:Date:In-Reply-To:Cc:To:References:From; b=ln1fo1SrYP7AVTM2J31fblDTy5JvpgxzSe6C8mNn+izPZvLJtyaEBkT61/Ry2kF6e xUnpavB7ifsDvx9/nu/q1r/CtLb3ili5FB1oWoR7ovi9XQ/KDMCb8Xr7h2pvNfGPH/ vLzPGXyvW4ERmuqSw74JHkSJMFoVpbs8cHd8Tx9Eda3tK0UxGrUOFP47os0qRGSX2j Pvq0/W2vVjc73+ffcJQi6Jp/vnmZieWm9XT9k9UmIN2b+uy0rXdc/3fvkl4f3XgYhd nhnnWQC8GemzhxanLx30iNSgbNsY+AVPFNrMXDobgVN52wGd52hIDXsW5QoOoq6Tqp 0/libRudVsYXA== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id BD3FB18068E for ; Fri, 31 May 2024 07:31: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-ed1-f44.google.com (mail-ed1-f44.google.com [209.85.208.44]) (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, 31 May 2024 07:31:03 +0000 (UTC) Received: by mail-ed1-f44.google.com with SMTP id 4fb4d7f45d1cf-57a31d63b6bso587347a12.0 for ; Fri, 31 May 2024 00:30:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1717140600; x=1717745400; darn=lists.php.net; h=references:to:cc:in-reply-to:date:subject:mime-version:message-id :from:from:to:cc:subject:date:message-id:reply-to; bh=P7DyvLOQNmm7Fn5fs4ZcJbzO8xsDOUNk4+zie0bSiUI=; b=anfYdX5KyMRWTWjFIDaIKA1eJnUNdM527ypwuZ6f/yxfKpiqsF9/dkEj37TB3FPoFy n1hYNtPsRpzp2Dh1SSAR5+nwAcJUZZj322UFZOFaCq1E1P/SvD9W4nqpcpQmwMw3l4F9 UeNt2l1kuuwKPGU+Z8Jaw2fysqW4LAZbMVHU5srIxaqyndDTdxQIBpFPnZychte9v6hC MHd3sE7sfbon3+lv6vLqFvTfkvLMhQ7X3rfudZS5E8Bbhj/r5QCLj9sNdepVQtNGYEzF L3OBXK3tRaTeXcDfWlrphIE4JMjwmRNaBkJUSOMyeUBrHBLNs8f8kD0YNSwt+eC6K63q Wjxg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1717140600; x=1717745400; h=references:to:cc:in-reply-to:date:subject:mime-version:message-id :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=P7DyvLOQNmm7Fn5fs4ZcJbzO8xsDOUNk4+zie0bSiUI=; b=e2Jk/1uERHncQbdolnuTEiVheRRw9SjnyeA/ugK/ozrQ8XfvMfZ/EFL9EYsqI62XqC r38UTd5abOq9vPuMagdd2Gn4e0U8NAQD2k5a/4kLRwAfpG6G737kos9C5BpSdoRgw2Oi BgnrrmpbHKhEDAEtKOH8THqvHc2L9GG6uPqp1YJQ8z72H2TRBIxL6zoPZIG2QMGCo77D IXpUmbSFMywqF84WBWlnsCB/Q2n5613S79yTwWL8umioPTDPMDuFwIGEoYJ3jiKYB3eZ lMwkla6kJJ51gwl1YIXt1qg8zMeTwagg+YGZ0kK5GI7crT1KvWLpucivD3bAB1THoFi7 5bUw== X-Forwarded-Encrypted: i=1; AJvYcCU832Uk175vw616bJ6cYeOwChD8CLfMfigkLL1+6TPPYxy7fW+djwlcbw/1p9EOMBYOxGSkov3JwlzrPusN9Zd3O6CqyJBw6A== X-Gm-Message-State: AOJu0YyIprQs2QEdO/+fWLqjIrt/cTN1PDVxo1WSPSPNhJRv3Zi+97TS w4bgruMv0JeK3hNMTBIczRIcYl0eP5kx3Ke+rQRIEzWrwbHyFfCLaxcE/w== X-Google-Smtp-Source: AGHT+IGE/Bc/lL7SvAjRImwAaOoDievNILKwfB9eZ38gmoRM2zKH5eTl30V/YvpVGeSOmW/fedDdTA== X-Received: by 2002:a17:907:910a:b0:a59:a83b:d435 with SMTP id a640c23a62f3a-a682041e845mr66498666b.18.1717140600175; Fri, 31 May 2024 00:30:00 -0700 (PDT) Received: from smtpclient.apple ([89.249.45.14]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a67e6f03217sm57175466b.22.2024.05.31.00.29.58 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Fri, 31 May 2024 00:29:59 -0700 (PDT) Message-ID: Content-Type: multipart/alternative; boundary="Apple-Mail=_EBF7760A-FD98-430A-A224-196451832BE0" Precedence: bulk list-help: list-post: List-Id: internals.lists.php.net Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3774.600.62\)) Subject: Re: [PHP-DEV] [RFC] Asymmetric Visibility, v2 Date: Fri, 31 May 2024 09:29:48 +0200 In-Reply-To: Cc: =?utf-8?Q?Alexandru_P=C4=83tr=C4=83nescu?= , php internals To: Derick Rethans References: <0a6a61cd-f203-4dea-a7f8-97e6b885c52d@app.fastmail.com> X-Mailer: Apple Mail (2.3774.600.62) From: claude.pache@gmail.com (Claude Pache) --Apple-Mail=_EBF7760A-FD98-430A-A224-196451832BE0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=utf-8 > Le 30 mai 2024 =C3=A0 17:07, Derick Rethans a =C3=A9cri= t : >=20 >>=20 >> Now, if I define the property as public private(set) with similar=20 >> intentions, to make sure that there is no way for external scope or=20= >> extending classes scope to write to the property, while allowing=20 >> reading from external scope (or extending classes scope). >>=20 >> But the problem is that an extending class can define the property as=20= >> public protected(set), and that will easily allow the property that I=20= >> wanted to make sure it is private for writing to be changed by an=20 >> extending class to be protected. >=20 > public private(set) properties aren't really private, so you don't get=20= > the shadowing, but you do have a point wrt to the expectation that an=20= > inherited class can't easily override the private(set) part (with=20 > protected(set) or public(set)). Note that the issue already exists today with readonly properties: those = are basically private(set); but if you redeclare a non-private readonly = property in a subclass, you can in fact initialise it from the subclass = bypassing the initial private(set) restriction of the superclass: = https://3v4l.org/9AV4r If you want a property not to be overridable, end of story, you can mark = it as `final` (the final marker for properties was added as part of the = hooks RFC, but it works also with non-hooked properties). =E2=80=94Claude= --Apple-Mail=_EBF7760A-FD98-430A-A224-196451832BE0 Content-Transfer-Encoding: quoted-printable Content-Type: text/html; charset=utf-8

Le 30 mai 2024 =C3=A0 17:07, Derick Rethans = <derick@php.net> a =C3=A9crit :


Now, if = I define the property as public 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), = 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.

public = private(set) properties aren't really private, so you don't get 
the shadowing, but you do have a point wrt = to the expectation that an 
inherited class can't easily override the = private(set) part (with 
protected(set) or public(set)).


Note = that the issue already exists today with readonly properties: those are = basically private(set); but if you redeclare a non-private readonly = property in a subclass, you can in fact initialise it from the subclass = bypassing the initial private(set) restriction of the = superclass: https://3v4l.org/9AV4r

<= /div>
If you want a property not to be overridable, end of story, = you can mark it as `final` (the final marker for properties was added as = part of the hooks RFC, but it works also with non-hooked = properties).

=E2=80=94Claude
= --Apple-Mail=_EBF7760A-FD98-430A-A224-196451832BE0--