Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:127511 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 1CA201A00BC for ; Fri, 30 May 2025 16:38:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1748623008; bh=Y5shhejJogtpAJ0iq2RpP+TK5Sj8hAiQMd5y8TGj4Ls=; h=Date:From:To:CC:Subject:In-Reply-To:References:From; b=gd8m0nJBiCtnBKqLu+PrioDdF5QHouxcvFBd6UlyHHokQYUZ1R4y/EXQPx3SjMFUo AfQYZr5J+KkuEjttSAxa0R1WzGakv+8j9AHte56w3mar88e5ezDF2h7GYk4sAC5Nu9 Q+ONf5i9hLkeW2bbuzJvzXbq3mxYq2T8jden8pfBmbo6ob8pdy98DG6ZOQ2TBKKky3 gT6TRPW6FKdAzO1GEEltYH30CZTJzK214iQFmNVojpI+/BypnfmZu6lOkTDKdX4EOs 9djg4PSUwahgmKhke+i/N4mbguHq5GFiJhT6IzBCP43FrPVGiOzRuiQ61zA8KOkEov g4aCN72I1qXIA== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 26851180087 for ; Fri, 30 May 2025 16:36:47 +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.9 required=5.0 tests=BAYES_20,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,DMARC_MISSING,RCVD_IN_DNSWL_LOW, SPF_HELO_PASS,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 fhigh-b1-smtp.messagingengine.com (fhigh-b1-smtp.messagingengine.com [202.12.124.152]) (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 16:36:46 +0000 (UTC) Received: from phl-compute-04.internal (phl-compute-04.phl.internal [10.202.2.44]) by mailfhigh.stl.internal (Postfix) with ESMTP id 23916254013F for ; Fri, 30 May 2025 12:38:52 -0400 (EDT) Received: from phl-mailfrontend-02 ([10.202.2.163]) by phl-compute-04.internal (MEProxy); Fri, 30 May 2025 12:38:52 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rwec.co.uk; h=cc :cc:content-transfer-encoding:content-type:content-type:date :date:from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:subject:subject:to:to; s=fm1; t=1748623131; x=1748709531; bh=Y5shhejJogtpAJ0iq2RpP+TK5Sj8hAiQMd5y8TGj4Ls=; b= lB6LTYDaiZJB+9zcZp9jLZQBChIoMG9zBcaoANRBoOhzivCvOgP/8Yi+83D5M9HY lKiTkkhutLQ5RItSab5QU6WjmV6G2KimMj+f1iI3BgVcn1DFS+DQL33XfKmqoDFO n47aKngduBbybn3xR6gXNduBHWqVFuZ0Egmnwab1ICdPia8FfVzC3r3g353PTO1s brA11Nf4vMYys8uQfmFeZ/4VbNBwSyXWqoeIiKvlDp29vGv+URpJLWUfXNn4qS3A /rLtEsrXUc71rcf6YtMMPFkm7ZIkwAf69xfM8NW/X5s42Mj86M8kMEx8t5gcVhsY xT9HlSU4vL1VHHP1RGLdLw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:content-type:date:date:feedback-id:feedback-id :from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:subject:subject:to:to:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm1; t=1748623131; x= 1748709531; bh=Y5shhejJogtpAJ0iq2RpP+TK5Sj8hAiQMd5y8TGj4Ls=; b=D 7wPgoAlKxUirbc/SDI4ruXbw52K+FF2SucRsHFcwsJylKAhfgLncSbatJscjT3Yc fDN9TC/M1D/uwjXJfosdQL3sJIp1MaQ9E5BYL5bR7XXrUYSNQ5iDxl/vLtC/mNAy 4NV8lIrbDg2kHqCHXkImr5YAGNdc+EB21ZwpkmtoAnZykm5kNKSHkutC2vmXqsPC bNz5/dobE55tSUIbWgcQEV4vfCs4Z5KDJ0cG5SZl6sWb7sbX0d/8QEhvLJ+aCd7y 486ptTEk1lP7vCqzz42nGjBKRo5kv5O6YTtviLsAIOJOc/h9k6ZChxJckoDo5E2J 4m13aS84Z3KtqRN/GVpKw== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeeffedrtddtgddvleehudculddtuddrgeefvddrtd dtmdcutefuodetggdotefrodftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpggft fghnshhusghstghrihgsvgdpuffrtefokffrpgfnqfghnecuuegrihhlohhuthemuceftd dtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenucfjughrpeffhffvvefufggj fhfkgggtgfesthhqmhdttderjeenucfhrhhomhepfdftohifrghnucfvohhmmhhinhhsuc glkffoufhorfgnfdcuoehimhhsohhprdhphhhpsehrfigvtgdrtghordhukheqnecuggft rfgrthhtvghrnhepuefgjeefgffhvdduvdeijefhfeefleeujeeihefftdegtddvteduud efudekueeunecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhho mhepihhmshhophdrphhhphesrhifvggtrdgtohdruhhkpdhnsggprhgtphhtthhopedupd hmohguvgepshhmthhpohhuthdprhgtphhtthhopehinhhtvghrnhgrlhhssehlihhsthhs rdhphhhprdhnvght X-ME-Proxy: Feedback-ID: id5114917:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA for ; Fri, 30 May 2025 12:38:50 -0400 (EDT) Date: Fri, 30 May 2025 17:38:48 +0100 To: internals@lists.php.net CC: PHP Internals Subject: Re: [PHP-DEV] Module or Class Visibility, Season 2 User-Agent: K-9 Mail for Android In-Reply-To: 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> Message-ID: <44F59416-3922-4AF4-881A-C64F2C4E9345@rwec.co.uk> Precedence: bulk list-help: list-post: List-Id: internals.lists.php.net x-ms-reactions: disallow MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable From: imsop.php@rwec.co.uk ("Rowan Tommins [IMSoP]") On 30 May 2025 08:57:34 BST, Rob Landers wrote: > >I=E2=80=99m starting to think that maybe modules might be a bad idea; or = at least, class/module visibility=2E > >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=2E During the extraction I realized that many of the classes and fu= nctions I was relying on actually used @internal classes/functions=2E If = =E2=80=9Cmodule=E2=80=9D visibility were a thing=E2=80=A6 would my implemen= tation have been possible? > >In other words, if visibility comes with modules; there really needs to b= e some kind of escape hatch=2E Some way to say, =E2=80=9CI know what I=E2= =80=99m doing, so get out of my way=2E=E2=80=9D Isn't this exactly the same as any other "access control" feature? We have private/protected methods and properties, final methods and classe= s, readonly properties; other languages also have sealed classes, module an= d/or file private, etc=2E 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 *acc= identally* violating assumptions the code is relying on=2E They are of course not *security* measures, as they can be bypassed via Re= flection or just editing the source code=2E 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=2Ee=2E fork it rather = than relying on the distributed version=2E=20 In your example, the author clearly marked that those classes were interna= l implementation details; if you use them directly and later update the lib= rary, you risk your code breaking either completely or subtly=2E If you cop= y them into your own codebase, you are free to remove the "@internal" annot= ations, or future "module private" declarations, and make whatever other ch= anges are needed to suit your use case=2E Regards, Rowan Tommins [IMSoP]