Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:127517 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 61AD91A00BC for ; Sat, 31 May 2025 12:03:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1748692897; bh=AfRve6upzNyCbJCOw5YyjGjIq4/clIaVIpS02o5fwmU=; h=Subject:From:In-Reply-To:Date:Cc:References:To:From; b=O8LLUj3/2uaESpykBu0Ri+MrEJK5R+IWd0AOrbPjYOFSPIHTvW/vSUkmzalglbEj4 h0MgOmQQSaDHgnHk6qpVp7pU8jwueq3r/uS6rP/I0FIUC1fAbi4XEzIYev2y8eZ28c DK992fDKbNtQYwCU9plDEpMFel1NYd9Wdt7vDpvN5Pb3Lolqj6i/wQTiEiQ95kHK2J mOfBLhbHBK948vRRtFdxOgAGhpxgKsRceGjQnJq2ofGwsUDEjBtYaeK8vlCINqLiMS lY0FzB4iEWTPoDSBgc6UYkjsZXdR2JhEHaLumD+hM5Nl0/hOcvge0t2/gV2SbFbAVc Hcofb5Ol3HuuQ== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 58D15180082 for ; Sat, 31 May 2025 12:01:36 +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-cluster4-host9-snip4-2.eps.apple.com [57.103.84.85]) (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 ; Sat, 31 May 2025 12:01:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=garsi.de; s=sig1; bh=AfRve6upzNyCbJCOw5YyjGjIq4/clIaVIpS02o5fwmU=; h=Content-Type:Mime-Version:Subject:From:Date:Message-Id:To:x-icloud-hme; b=W86qaSVhLSIkkIjz7E3LhGgv6tce5Y8f5TkSHwS7L4B+YBLpfuED+iGYJT6gcuZ/l 91+UsIRO4OAW89tZiDLlEPzrMrfDdIifdVLV8guTyaYpUsEoRIoQmxdQ3l8xzfSqte 8Or1jibvveTh2YAHg49MelIHzjk5S5swHLpxsqesF9to2gwGFIqxtvCUoU1kOa5PVj E6SjU1nuYz3TV4XLqHCwYfPBa7LP8k0SbS0tsOh5zrciSxLigR8L2oz+TrwS/AWQ1O vYvMbL63u3DFneTwjHG/DGz9Fl0iXk8pwH0xW6KFfl/z+2XE6Sw1IOTaCM5GIZLQBz PqqFyg/Ky8b4Q== Received: from outbound.qs.icloud.com (localhost [127.0.0.1]) by outbound.qs.icloud.com (Postfix) with ESMTPS id 66BA31800D5D; Sat, 31 May 2025 12:03:30 +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 5CF071800DB7; Sat, 31 May 2025 12:02:55 +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: <7840468C-F60C-4A44-AE40-16F9007EF428@rwec.co.uk> Date: Sat, 31 May 2025 14:02:43 +0200 Cc: PHP Internals Content-Transfer-Encoding: quoted-printable Message-ID: <160E9B1D-9AF6-479B-A628-A73C618D7C1B@garsi.de> References: <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> <7F11844A-A98C-4843-BC94-815FBCD2B73F@garsi.de> <7840468C-F60C-4A44-AE40-16F9007EF428@rwec.co.uk> To: "Rowan Tommins [IMSoP]" X-Mailer: Apple Mail (2.3826.500.181.1.5) X-Proofpoint-GUID: vKurfAXkneiXIidQAVGbufwwc38HMT0Y X-Proofpoint-ORIG-GUID: vKurfAXkneiXIidQAVGbufwwc38HMT0Y 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-31_05,2025-05-30_01,2025-03-28_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 mlxscore=0 adultscore=0 phishscore=0 malwarescore=0 clxscore=1030 bulkscore=0 spamscore=0 mlxlogscore=999 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.22.0-2503310001 definitions=main-2505310108 From: alwin@garsi.de (Alwin Garside) On 30 May 2025, at 21:29, Rowan Tommins [IMSoP] = wrote: >=20 > On 30 May 2025 19:21:08 BST, Alwin Garside wrote: >> 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]`. >=20 >=20 > I don't see any reason for the message to be any quieter or easier to = override than calling a private method. If there were a dedicated `internal` modifier keyword, sure. However if = one simply wants to advertise clearly to other developers that they = should expect the code to break anytime using an attribute, I feel a = compile-time critical error is a bit too strict. >=20 > Indeed, one use of an internal/module-private feature would be when = the author wants to split up a class that has a large number of private = methods: the new classes need to be able to talk to each other, so the = existing "private" keyword is no longer appropriate, but the intended = surface to users of the library has not changed. The user is making = exactly the same decision by ignoring the "internal" flag as they are if = they use reflection or code-rewriting to ignore/remove the "private" = flag. I understand your point, but playing devil's advocate for a minute here: = I'd argue that if a class reaches the point where it has too many = private methods, something has clearly gone wrong in the architecture or = abstraction of that class. It probably means part of the functionality = needs to be hoisted out to a separate class with its own self-contained, = stable interface. One could also argue that if the author really wishes to break private = methods up across multiple classes, they could also use reflection (or = preferably: a method call wrapped in a closure bound to the target = class) to access their own private methods. My experience with module-level visibility out in the wild (mostly in = Java), has mostly been libraries where the authors apparently couldn't = be bothered to dedicate to a stable interface for more specific = implementations of certain template-pattern adapters and the like =E2=80=93= the Android source code is full of this. [rant] I specifically remember dealing with a DB adapter interface and = accompanying abstract class, along with implementations for several = DBMSs. There was an implementation for the specific DBMS I wanted to = use, however, per the interface, it was completely tied into a separate = pagination construction which led to a leaky abstraction, and was badly = optimized for my use case. I just needed to override one or two methods = to make it work for me, but the platform visibility on those methods = meant I had to copy-paste both the abstract class and the adapter class = to fix the functionality, giving me more code to maintain in the = process. I think this is a good example where package/module-level visibility = makes developers complacent, and not care about offering a library that = is easy to extend or encapsulate. [/rant] Alwin=