Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:127451 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 CD22F1A00BC for ; Sun, 25 May 2025 08:27:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1748161548; bh=eU2BwuFNz6iInsJ1vTUDI25BYpCSDIpDfc8ok3h0mLY=; h=Date:From:To:In-Reply-To:References:Subject:From; b=UdrurwD/oVR00nH+07X4ljmdNhuB7PhUG2RAoklSpb8QkG/T6nQ2ExckZ/1wpnlUl Un/BbeFVvYfEo5qByapkNrZ5E2CoE679dfo29Umu0LDpQw+EEj7lV2X2EiHwhBXLxP fT0jIRzvw0RoU2dcoIeeOWO0pkVEZLkRTVC36Ao8iGXxY2q9HSco/vMF02yiES/XR2 w0NkZlKFLi/ulBCD4kWNyEg9PpX4NyVKyoKne/6DmFcC+WydhVgh3M+HjCXh7mTKro lAXYIMa5LEi21Yes/ocu/1iIQ4CPY6TVFhfh/l9iDMAYBN+n9qleRvEHkCbnattqLf +apF60rXm0kNw== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id ED705180034 for ; Sun, 25 May 2025 08:25:46 +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=-2.4 required=5.0 tests=BAYES_05,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,DMARC_MISSING,HTML_MESSAGE, RCVD_IN_DNSWL_LOW,RCVD_IN_MSPIKE_H5,RCVD_IN_MSPIKE_WL,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-a7-smtp.messagingengine.com (fout-a7-smtp.messagingengine.com [103.168.172.150]) (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, 25 May 2025 08:25:46 +0000 (UTC) Received: from phl-compute-05.internal (phl-compute-05.phl.internal [10.202.2.45]) by mailfout.phl.internal (Postfix) with ESMTP id 9B847138013C for ; Sun, 25 May 2025 04:27:53 -0400 (EDT) Received: from phl-imap-09 ([10.202.2.99]) by phl-compute-05.internal (MEProxy); Sun, 25 May 2025 04:27:53 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bottled.codes; h=cc: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=1748161673; x=1748248073; bh=KNpJOcVWgA dzd+h8G3rHCgrCdTB3td65Vk1sDIDACTQ=; b=P7dxdnEA9mMKuA7JMhYnyEcqzr NmDS4P9tLSNBMvFBaCivHNg7m3Pl1EmQcL/DfkQkW+H6YKAbATXuRzkiwThyCJrN K1uzQF1rM3J2gvmVnsS+bcSexoOYl9wKljtYIIghlG9GCL30N/6R1jxyxmjbGxDO 2xkqTNOp+mf2xEd7caEh2aazCS6Zt+i318gOVzb07hwpt1a/pUdZ9DMLmWyIu+Qm hoEo0JLt2myQlwE/hhgpQDq5Oi68fHkjst2iqu1vUhwbjJELB0vwFZwoAFuT+9MC LqSocNf4X47oYOqdCzIOEQtGrKY2OX3oeJcLK5yNklx8qF7s0TMo+ISYHsbA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc: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= 1748161673; x=1748248073; bh=KNpJOcVWgAdzd+h8G3rHCgrCdTB3td65Vk1 sDIDACTQ=; b=pQ0Dv3oI2TXgIC7WxJa722jVnoubA8nFLMMEmz5XCQYoB7ye8ov 2VE72filEESIqYHfUJoNh9Z88LUTLU76PKYLu33xboMSl2NbZLBQgjBkYKO8Cvf7 YASh1fBqCC7nGrT75rT2h5OkBDusVvs/l7a+FpFgUpFQcLwFJVs0L7TFJM5gpm1n k2yzceYzjGVO4s5ZuBkJmQzhRhXoFCPZadnCBemVDxeS0cw/heNsgVv2j0q9K82U bJccpT9CTVZntUe1Du+F1I9/wSm6yWJebdT/qxCkZiG9NoN5WAx6a1VlRbkMp0FO Kap8Mij0Apa3v46SkQa6rTRrgSzNf3rDlOA== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeeffedrtddtgddugeduvdculddtuddrgeefvddrtd dtmdcutefuodetggdotefrodftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpggft fghnshhusghstghrihgsvgdpuffrtefokffrpgfnqfghnecuuegrihhlohhuthemuceftd dtnecunecujfgurhepofggfffhvffkjghfufgtsegrtderreertdejnecuhfhrohhmpedf tfhosgcunfgrnhguvghrshdfuceorhhosgessghothhtlhgvugdrtghouggvsheqnecugg ftrfgrthhtvghrnheptdeujedttefhueelhfdtleeiudetlefftdduleehffegtdeihefh leeijefgveegnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrh homheprhhosgessghothhtlhgvugdrtghouggvshdpnhgspghrtghpthhtohepuddpmhho uggvpehsmhhtphhouhhtpdhrtghpthhtohepihhnthgvrhhnrghlsheslhhishhtshdrph hhphdrnhgvth X-ME-Proxy: Feedback-ID: ifab94697:Fastmail Received: by mailuser.phl.internal (Postfix, from userid 501) id 2C2B5302005F; Sun, 25 May 2025 04:27:53 -0400 (EDT) X-Mailer: MessagingEngine.com Webmail Interface Precedence: bulk list-help: list-post: List-Id: internals.lists.php.net x-ms-reactions: disallow MIME-Version: 1.0 X-ThreadId: T018bd9ffc60205f7 Date: Sun, 25 May 2025 10:27:32 +0200 To: internals@lists.php.net Message-ID: In-Reply-To: <79E7FA26-2F5A-470C-B1DF-12CC46A08FE5@rwec.co.uk> References: <9A26F72B-D0EF-414F-B193-BED3CAB26A0B@rwec.co.uk> <9f6a0d6e-27c3-4f77-aed6-e55147442b6f@app.fastmail.com> <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> Subject: Re: [PHP-DEV] Module or Class Visibility, Season 2 Content-Type: multipart/alternative; boundary=da6080eef648483cb00698cffd41726f From: rob@bottled.codes ("Rob Landers") --da6080eef648483cb00698cffd41726f Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On Sat, May 24, 2025, at 23:18, Rowan Tommins [IMSoP] wrote: > On 24 May 2025 14:11:57 BST, Rob Landers wrote: > >My only concern is how this would be handled in the class tables. Rig= ht now, \AlicesCalendar\Monolog\Logger and \BobsDocs\Monolog\Logger woul= d be considered entirely different types -- as in, not compatible. So if= AlicesCalendar returns a type that BobsDocs expects, they won't be able= to talk to each other. >=20 > Once again, I'd like to use the Linux Container analogy: a process in = one container never communicates directly with a process in another cont= ainer. The process "thinks" it's running as normal, but is actually isol= ated inside a sandbox. The container then defines the inputs and outputs= it wants to open between that sandbox and the host, and something runni= ng on the host can wire those up as necessary. >=20 >=20 >=20 > >I assume that it will be up to a dependency resolver (either composer= or something else) will need to figure out which direct dependencies to= "hoist" up and provide a compatible version between the two packages. >=20 > I see this as the responsibility of each "container": if AlicesCalenda= r wants to use an un-sandboxed version of a PSR interface or a framework= component, it declares that to the "host" (e.g. WordPress core). The PH= P engine then knows to leave that interface name without a prefix. Any o= ther class - whether it's written by Alice or installed by Composer - ex= ists inside the sandbox, and gets a prefix. >=20 > Importantly, all of this should happen on the *PHP symbol* level (clas= ses, interfaces, functions); the sandboxing mechanism doesn't need to kn= ow about package managers - just as Docker, Kunernetes, etc, don't know = about APT / Yum / whatever Apine calls it. >=20 > Rowan Tommins > [IMSoP] >=20 Yes, that aligns with what I was thinking too, for the most part. Here are my thoughts, but first some vocabulary: - direct dependency: a package that is used by the current package - exported dependency: a direct dependency that can be used outside the = current package - peer dependency: an indirect dependency on another package that isn=E2= =80=99t required to function but may offer additional functionality if i= nstalled. I have no idea how this would be defined or used yet. - package: the physical artefact containing one or more modules. Thinking back on several of my implementation explorations of nested cla= sses, it should be possible to identify if a dependency/class is able to= be used outside the package during compilation. So, I don=E2=80=99t thi= nk we need the user to explicitly state an exported dependency. In other= words (and making up some syntax): use module AlicesCalendar; use module BobsDocs; // AlicesCalendar needs to be "exposed" outside the package public function doSomething(\AlicesCalendar\Week $week) { /* do stuff */= } // BobsDocs remains an internal-only dependency private function otherSomething(\BobsDocs\Doc $doc) { /* do stuff */ } When compiling, we will see a public function "exposing" a direct depend= ency. Thus we would know that the current module would need to export th= e direct dependency on AlicesCalendar. This would prevent the developer = from having to keep track of all the dependencies that need to be export= ed. From a developer=E2=80=99s point of view, they would use it like nor= mal. So, you could imagine a generated package manifest might look something = like this: { "rootNamespace": "OfficeSuite" "dependencies": {=20 "AlicesCalendar": "^1.0.0",=20 "BobsDocs": "^0.1.0"=20 }, "exports": {=20 "dependencies": ["AlicesCalendar"],=20 "functions": ["OfficeSuite\doSomething"], "classes": [] } } A package manager (IDE, or even a human) could then surmise what package= s they need to be shared between modules. It would also know that BobsDo= cs is entirely private to the module, so it doesn=E2=80=99t need to be c= ompatible with any other module using BobsDocs. Anyway, this is a bit into the weeds, but I want to point out what is po= ssible or not, based on my experience working on nested classes. In othe= r words, I=E2=80=99m 99% sure we can infer exported dependencies without= requiring a human to manually do the work; what that actually looks lik= e in practice is still very much in the air. So, please don=E2=80=99t ta= ke the above as an actual proposal, but as inspiration. =E2=80=94 Rob --da6080eef648483cb00698cffd41726f Content-Type: text/html; charset=utf-8 Content-Transfer-Encoding: quoted-printable
On Sat, May = 24, 2025, at 23:18, Rowan Tommins [IMSoP] wrote:
On 24 May 2025 14:11:57 BST, Rob Lander= s <rob@bottled.codes> wro= te:
>My only concern is how this would be handled in the cl= ass tables. Right now, \AlicesCalendar\Monolog\Logger and \BobsDocs\Mono= log\Logger would be considered entirely different types -- as in, not co= mpatible. So if AlicesCalendar returns a type that BobsDocs expects, the= y won't be able to talk to each other.

Once aga= in, I'd like to use the Linux Container analogy: a process in one contai= ner never communicates directly with a process in another container. The= process "thinks" it's running as normal, but is actually isolated insid= e a sandbox. The container then defines the inputs and outputs it wants = to open between that sandbox and the host, and something running on the = host can wire those up as necessary.


=

>I assume that it will be up to a dependency reso= lver (either composer or something else) will need to figure out which d= irect dependencies to "hoist" up and provide a compatible version betwee= n the two packages.

I see this as the responsib= ility of each "container": if AlicesCalendar wants to use an un-sandboxe= d version of a PSR interface or a framework component, it declares that = to the "host" (e.g. WordPress core). The PHP engine then knows to leave = that interface name without a prefix. Any other class - whether it's wri= tten by Alice or installed by Composer - exists inside the sandbox, and = gets a prefix.

Importantly, all of this should = happen on the *PHP symbol* level (classes, interfaces, functions); the s= andboxing mechanism doesn't need to know about package managers - just a= s Docker, Kunernetes, etc, don't know about APT / Yum / whatever Apine c= alls it.

Rowan Tommins
[IMSoP]
<= div>

Yes, that aligns with wha= t I was thinking too, for the most part.

Here a= re my thoughts, but first some vocabulary:
- direct dependency= : a package that is used by the current package
- exported dep= endency: a direct dependency that can be used outside the current packag= e
- peer dependency: an indirect dependency on another package= that isn=E2=80=99t required to function but may offer additional functi= onality if installed. I have no idea how this would be defined or used y= et.
- package: the physical artefact containing one or more mo= dules.

Thinking back on several of my implement= ation explorations of nested classes, it should be possible to identify = if a dependency/class is able to be used outside the package during comp= ilation. So, I don=E2=80=99t think we need the user to explicitly state = an exported dependency. In other words (and making up some syntax):

use module AlicesCalendar;
use module Bob= sDocs;

// AlicesCalendar needs to be "exposed" = outside the package
public function doSomething(\AlicesCalenda= r\Week $week) { /* do stuff */ }

// BobsDocs re= mains an internal-only dependency
private function otherSometh= ing(\BobsDocs\Doc $doc) { /* do stuff */ }

When= compiling, we will see a public function "exposing" a direct dependency= . Thus we would know that the current module would need to export the di= rect dependency on AlicesCalendar. This would prevent the developer from= having to keep track of all the dependencies that need to be exported. = From a developer=E2=80=99s point of view, they would use it like normal.=

So, you could imagine a generated package mani= fest might look something like this:

{
  "rootNamespace": "OfficeSuite"
  "dependencies":= {
    "AlicesCalendar": "^1.0.0",
 = ;   "BobsDocs": "^0.1.0"
  },
  "exp= orts": {
    "dependencies": ["AlicesCalendar"],
    "functions": ["OfficeSuite\doSomething"],
    "classes": []
  }
}
=
A package manager (IDE, or even a human) could then surmi= se what packages they need to be shared between modules. It would also k= now that BobsDocs is entirely private to the module, so it doesn=E2=80=99= t need to be compatible with any other module using BobsDocs.
=
Anyway, this is a bit into the weeds, but I want to point= out what is possible or not, based on my experience working on nested c= lasses. In other words, I=E2=80=99m 99% sure we can infer exported depen= dencies without requiring a human to manually do the work; what that act= ually looks like in practice is still very much in the air. So, please d= on=E2=80=99t take the above as an actual proposal, but as inspiration.

=E2=80=94 Rob
--da6080eef648483cb00698cffd41726f--