Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:127512 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 lists.php.net (Postfix) with ESMTPS id 49C2C1A00BC for ; Fri, 30 May 2025 18:21:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1748629158; bh=UzqUvFmZRHnMTVEPOXp078TRgM+0UnQDpAtnL9lLH1Q=; h=Subject:From:In-Reply-To:Date:Cc:References:To:From; b=GF1085N1UO9iyPYxuMu2auUKoubnaqH4Z5LiLIL6EPhrExy1eWbdkLRrGx29QVBk3 zbY2A5gtTRDjFjeSyofUVSjkjW4qj+8B3jptgq/fpoUr+BDNipWGhV248u/iYwAXSG UrUHg9s27anjbCO53nu12UKfAUu9HoDsrYAYyUQWIFOswBfomO1/6WQyOMnFwkxtJz JPRHZbEB8tp1kC0+Gv9E5gyBAjN5C9ny8Hd8gEYkrVykHl4cPFyI0PVHEL/Cj2LhhX 3PHhbrYyCzQcIYPd+ZcUaDEGT1IdR3L96hxQD97ExwxfdvoWspWPrLxmoHbokCxB62 nPbYc5qN19ODQ== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 01E9618002F for ; Fri, 30 May 2025 18:19:17 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on php-smtp4.php.net X-Spam-Level: X-Spam-Status: No, score=-0.7 required=5.0 tests=BAYES_05,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,DMARC_PASS,SPF_HELO_NONE, SPF_PASS autolearn=no autolearn_force=no version=4.0.1 X-Spam-Virus: Error (Cannot connect to unix socket '/var/run/clamav/clamd.ctl': connect: Connection refused) X-Envelope-From: Received: from outbound.qs.icloud.com (p-east3-cluster2-host11-snip4-5.eps.apple.com [57.103.87.236]) (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, 30 May 2025 18:19:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=garsi.de; s=sig1; bh=4dBP2yaLi8xhMHzwhnJ85dpjDYm3z0FeKekRCwpJ24o=; h=Content-Type:Mime-Version:Subject:From:Date:Message-Id:To:x-icloud-hme; b=Gh6lBiwYyarEAomhdvNC5wov49apBcVpqsBR3ONjWdz3nDKj1r8T3kg+k7R8wYh2b 4Q7AQomE98k0fPHC1Pw2s7e2w/sXpso6KW9I5fMrwLPv3uAAI0aryw2mpPOusbZvAn ylqD7NCiK1ranlsLJq/xz1F0qR+KUbG5YQPLP7X8/ciYQdto2oanW3Rx2tmrarrlMS U0Sw+LBY2jHeO67m5CasikufMBS6onqwwUk31Rx2AcOMM0FEllbqk+uCJ/S0MV4zVq 0TWlfXRm2SLkKxFcyL/DPYH2pPcNRyD9TCFuxOO+KybsqOvIDCbT44fjWRzZa7f4Xa r+NF1QfMAaqoA== Received: from outbound.qs.icloud.com (localhost [127.0.0.1]) by outbound.qs.icloud.com (Postfix) with ESMTPS id 08E64180018A; Fri, 30 May 2025 18:21:20 +0000 (UTC) Received: from smtpclient.apple (qs-asmtp-me-k8s.p00.prod.me.com [17.57.155.37]) by outbound.qs.icloud.com (Postfix) with ESMTPSA id E761D1800136; Fri, 30 May 2025 18:21:19 +0000 (UTC) Content-Type: text/plain; charset=utf-8 Precedence: bulk list-help: list-post: List-Id: internals.lists.php.net x-ms-reactions: disallow Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3826.500.181.1.5\)) Subject: Re: [PHP-DEV] Module or Class Visibility, Season 2 In-Reply-To: <44F59416-3922-4AF4-881A-C64F2C4E9345@rwec.co.uk> Date: Fri, 30 May 2025 20:21:08 +0200 Cc: PHP Internals Content-Transfer-Encoding: quoted-printable Message-ID: <7F11844A-A98C-4843-BC94-815FBCD2B73F@garsi.de> References: <673fd2db-b07f-439b-a4f2-e9519108d159@app.fastmail.com> <78641D8B-AF1D-4912-920A-D75A37C32F05@rwec.co.uk> <354cb888-97c4-4f8c-a0da-359d1e63c0f9@rwec.co.uk> <10D95B6E-094B-4EAE-A18A-AF6B795CB352@rwec.co.uk> <2adbff61-5e11-4d39-ab5c-d7950a4550a6@app.fastmail.com> <79E7FA26-2F5A-470C-B1DF-12CC46A08FE5@rwec.co.uk> <1c6dcd84-9016-48e1-971f-de7749cbdce8@rwec.co.uk> <44F59416-3922-4AF4-881A-C64F2C4E9345@rwec.co.uk> To: "Rowan Tommins [IMSoP]" X-Mailer: Apple Mail (2.3826.500.181.1.5) X-Proofpoint-ORIG-GUID: _yo-6IOlI7AylQjopjYf9bR0KHAVH7MK X-Proofpoint-GUID: _yo-6IOlI7AylQjopjYf9bR0KHAVH7MK X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1099,Hydra:6.0.736,FMLib:17.12.80.40 definitions=2025-05-30_08,2025-05-30_01,2025-03-28_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 bulkscore=0 spamscore=0 adultscore=0 mlxscore=0 clxscore=1030 phishscore=0 mlxlogscore=999 malwarescore=0 suspectscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.22.0-2503310001 definitions=main-2505300162 From: alwin@garsi.de (Alwin Garside) On 30 May 2025, at 18:38, Rowan Tommins [IMSoP] = wrote: >=20 > On 30 May 2025 08:57:34 BST, Rob Landers wrote: >>=20 >> I=E2=80=99m starting to think that maybe modules might be a bad idea; = or at least, class/module visibility. >>=20 >> As an anecdote, I was looking to extract a protobuf encoding library = from a larger codebase and create a separate library for Larry=E2=80=99s = Serde library. During the extraction I realized that many of the classes = and functions I was relying on actually used @internal = classes/functions. If =E2=80=9Cmodule=E2=80=9D visibility were a = thing=E2=80=A6 would my implementation have been possible? >>=20 >> In other words, if visibility comes with modules; there really needs = to be some kind of escape hatch. Some way to say, =E2=80=9CI know what = I=E2=80=99m doing, so get out of my way.=E2=80=9D >=20 >=20 > Isn't this exactly the same as any other "access control" feature? >=20 > We have private/protected methods and properties, final methods and = classes, readonly properties; other languages also have sealed classes, = module and/or file private, etc. All of these are ways for the author of = the code to express how they intend it to be used, and to protect users = against *accidentally* violating assumptions the code is relying on. >=20 > They are of course not *security* measures, as they can be bypassed = via Reflection or just editing the source code. >=20 > If you're using someone else's code in ways they didn't intend, that's = up to you, but you may need to make changes to do so, i.e. fork it = rather than relying on the distributed version.=20 If the goal is to hint consumers of a library about the (lack of) = guarantees regarding a method or its signature, then perhaps an = `#[\Internal]` attribute makes sense. ```php namespace Acme\Foo; class Foo { #[\Internal('Acme')] public function bar() { /* ... */ } } ``` In the example above, I image calling or extending the `Foo::bar()` = method from somewhere outside the `Acme` namespace would trigger an = E_USER_WARNING or E_USER_NOTICE. The warning/notice could then be = suppressed when explicitly overriding an `#[\Internal]` method with = `#[\Override]`. Alwin=