Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:127525 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 BCBF41A00BC for ; Sun, 1 Jun 2025 22:01:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1748815156; bh=S2xnet6Tpmrkq5Gq462LGoxOWXaQ8uQRqH8FhNvQH6s=; h=Date:Subject:To:References:From:In-Reply-To:From; b=CkpgazTr3yMKWwGsDncVuqQTeO+VJetUb7JMmCSbgZW2rvWpi5Inw3wg/KnjHn721 BfZ2MztHsUiB8URSebxDZ5VaxJTt7x8+4tnKl0xdEqfFLlJ0Sjow/batXHY9QtlU0N KsdyxM8WCOBGPxOc4bnRicYtke4j39B6ZZ4ZYWd2GNpmxTTovtvSkPSpXvDGCrEzUX ywISEMMurYiJUwgeax723r+2Szd8M5Yp9wLRX4e+VRVRhmKqPPxtVfg5Dc8LDKSbKK GmmEr0Nz0VIm+dv/0pacj+mYoDfF0bPMBYkm2NJmozRZ0iYu1QfCJxLzXXtCmWaGbA so2tEjlB5w/Tg== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id DA5E0180086 for ; Sun, 1 Jun 2025 21:59:14 +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.1 required=5.0 tests=BAYES_50,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 fout-b3-smtp.messagingengine.com (fout-b3-smtp.messagingengine.com [202.12.124.146]) (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 ; Sun, 1 Jun 2025 21:59:14 +0000 (UTC) Received: from phl-compute-03.internal (phl-compute-03.phl.internal [10.202.2.43]) by mailfout.stl.internal (Postfix) with ESMTP id A458111400B9 for ; Sun, 1 Jun 2025 18:01:18 -0400 (EDT) Received: from phl-mailfrontend-01 ([10.202.2.162]) by phl-compute-03.internal (MEProxy); Sun, 01 Jun 2025 18:01:18 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rwec.co.uk; h=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=1748815278; x=1748901678; bh=9NM9al/NiWfa37nWfa27tDFq8TJHk3431smMx+cgfv0=; b= uDCymB5mGQORRBQYk+Omt3JSDyYeO/ibGs0UFWXIpajgV9J7OJf9G4/0abftpJoh VhX/qUIo1KqsHRND1GSoTXkjQTDl3RJlTJ+Hdkqswby0/ANFmpjz8C9gt5nwNEKn igN7CR3xqLTl9MmKb31XvU7h5cknV9WO130pnCn/N1CGigNYhQhfujQZ/TAuaQIy av0nL1V89q9T8QzmEySxCLMLXWrB+UCynZ0kbRYvvX0b8c8gcQL2PnOE5Ya6J0Q1 icNpPi4soOE4YRnEfBKbD+CooJUfQaancH75jItn8sa7dgaifh7W37f5j3r7c6Ln pgo/oBqYxDOLj/pydW8arQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=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=1748815278; x=1748901678; bh=9 NM9al/NiWfa37nWfa27tDFq8TJHk3431smMx+cgfv0=; b=D9xJyOuGXF7Scdb2x ZL771I3hSyJThBK8cHHJVoec+NtU7zYz8+ZknP2H3CoMt0lXA/iogO1FyJ9AfPw7 aEdhKZX5qxmDsYtb8Ep2p1pXrY2D4sz29eWxtuvZk7cgWNusntD6RsRDssWYP9cu QdBsaYlTandS7GARUq7/ietG5BLCSvqZEZfSxcA0R4yQgnQc/L+SCzegz7P5bygG eZAXASta8+OjmqqkYLOofJqkdx49gKEEsML1MsNLiv9pwgH5SBaKJ9W0aucEfUDH jb+0CXDACFUV7HsQu/5iR8Ii8eChBmsAjoBXr9LnVYPh+Xk3J3u55BBU5k+0whlW Arohg== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeeffedrtddtgdefheelgeculddtuddrgeefvddrtd dtmdcutefuodetggdotefrodftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpggft fghnshhusghstghrihgsvgdpuffrtefokffrpgfnqfghnecuuegrihhlohhuthemuceftd dtnecunecujfgurhepkfffgggfuffvfhfhjggtgfesthejredttddvjeenucfhrhhomhep fdftohifrghnucfvohhmmhhinhhsucglkffoufhorfgnfdcuoehimhhsohhprdhphhhpse hrfigvtgdrtghordhukheqnecuggftrfgrthhtvghrnhepjeekgffhuefggfdtueehgefg udeghfdukeejhfetgeeijeelheevlefhfedvhfdunecuvehluhhsthgvrhfuihiivgeptd enucfrrghrrghmpehmrghilhhfrhhomhepihhmshhophdrphhhphesrhifvggtrdgtohdr uhhkpdhnsggprhgtphhtthhopedupdhmohguvgepshhmthhpohhuthdprhgtphhtthhope hinhhtvghrnhgrlhhssehlihhsthhsrdhphhhprdhnvght X-ME-Proxy: Feedback-ID: id5114917:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA for ; Sun, 1 Jun 2025 18:01:17 -0400 (EDT) Message-ID: <2c5c241c-bd05-4200-b6ee-e94c8ab0db1b@rwec.co.uk> Date: Sun, 1 Jun 2025 23:01:16 +0100 Precedence: bulk list-help: list-post: List-Id: internals.lists.php.net x-ms-reactions: disallow MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PHP-DEV] Module or Class Visibility, Season 2 Content-Language: en-GB To: internals@lists.php.net References: <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> <160E9B1D-9AF6-479B-A628-A73C618D7C1B@garsi.de> In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit From: imsop.php@rwec.co.uk ("Rowan Tommins [IMSoP]") On 01/06/2025 17:05, Larry Garfield wrote: > I think there's a key assumption here still that is at the root of much of the disagreement in this thread. > > Given that code from multiple files is clustered together into a "thing" > and Given we can use that "thing" to define a boundary for: > * name resolution (what Michael is after); > * visibility (what I am after); > * more efficient optimizations (what Arnaud showed is possible); > * various other things > Then the key question is: Who defines that boundary? > > Is it the code*author* that defines that boundary? Or is it the code*consumer*? > > Similarly, is it the code author or consumer that has to Do Work(tm) in order to leverage the desired capability? Or both? My take on this is that both need to exist as *separate* features. The author should define the boundary for things like visibility and optimisation. It should be possible to take an existing Composer package, add some metadata to it in some way, and have the engine make some useful assumptions. The consumer of that package should not need to care about the difference, except in edge cases like trying to define additional classes with the same prefix as a third-party package. On the other hand, the consumer should define the boundary for isolating name resolution. It should be possible to take any folder of PHP files, with no metadata about package management, and load it in a context where duplicate class names are allowed. The author of the package shouldn't need to make any changes, except in edge cases like highly dynamic code which needs additional hints to work correctly when sandboxed. The first feature is an add-on to the extremely successful ecosystem based on the assumption that packages will inter-operate based on agreed names. The second feature is a bridge between that ecosystem and the very different world of plugin-based web applications, which want to manage multiple pieces of code which are not designed to co-operate, and run them side by side. JS has come up a few times as a comparison, because there the two features overlap heavily. That's because the language has always started from the opposite assumption to PHP: declarations in JS are local by default, and can only be referenced outside of the current function scope if explicitly passed outwards in some way. In PHP - and Java, C#, and many others - the opposite is true, and declarations have a global name by default; keywords like "private" and "internal" are then used to indicate that although code can name something, it's not allowed to use it. Both have their strengths and weaknesses, but at this point every JS module going back 15+ years (CommonJS was founded in 2009, to standardise existing practices) is based on the "interact by export" model; and every PHP package going back 25+ years (PEAR founded in 1999; Composer in 2011) is based on the "interact by name" model. -- Rowan Tommins [IMSoP]