Newsgroups: php.internals
Path: news.php.net
Xref: news.php.net php.internals:125043
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 qa.php.net (Postfix) with ESMTPS id ACF691A00BD
	for <internals@lists.php.net>; Sun, 18 Aug 2024 21:51:10 +0000 (UTC)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail;
	t=1724017978; bh=aFD5NRyOkTCIrYMW439xz1620oCAHKNFm2ddh9fxvvs=;
	h=Date:From:To:Cc:In-Reply-To:References:Subject:From;
	b=LV2jK2gECyp64PAqXOSOmeKlviIPb+XXOeex6r8FUue/exqMUtQxTvBj10QikYcQy
	 XHs24rUcVpXiqtZV1e6gcv9tCWu+3O2GDVf2SOLzfa/lOqJiQqPaX29Jdlr49fIQAq
	 1bzoYXiBhwLqlGHLgaI3QX9V5LhggVdmWO5hC3CAd/g8Bw9Jt+VC7zNoKvKjrQyFT4
	 bNlHRBUsAdMctkKSltE7Gl7Hn0FYpo8SRi0EyZlCvFCqdjvKvz5qlEqhpRNE8C93GA
	 zSv/hD1dKderox0bvUtORvMXCs7gNZpOGj9gAWbYwdPNgVqKgOCO1bNYw1aF1ZO4pH
	 mqp5ereL4D2GQ==
Received: from php-smtp4.php.net (localhost [127.0.0.1])
	by php-smtp4.php.net (Postfix) with ESMTP id BF20018003E
	for <internals@lists.php.net>; Sun, 18 Aug 2024 21:52:54 +0000 (UTC)
X-Spam-Checker-Version: SpamAssassin 4.0.0 (2022-12-13) 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,HTML_MESSAGE,
	RCVD_IN_DNSWL_LOW,SPF_HELO_PASS,SPF_PASS autolearn=no
	autolearn_force=no version=4.0.0
X-Spam-Virus: No
X-Envelope-From: <rob@bottled.codes>
Received: from fout4-smtp.messagingengine.com (fout4-smtp.messagingengine.com [103.168.172.147])
	(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 <internals@lists.php.net>; Sun, 18 Aug 2024 21:52:53 +0000 (UTC)
Received: from phl-compute-03.internal (phl-compute-03.nyi.internal [10.202.2.43])
	by mailfout.nyi.internal (Postfix) with ESMTP id 136A6138FC72;
	Sun, 18 Aug 2024 17:51:05 -0400 (EDT)
Received: from phl-imap-09 ([10.202.2.99])
  by phl-compute-03.internal (MEProxy); Sun, 18 Aug 2024 17:51:05 -0400
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bottled.codes;
	 h=cc: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=1724017865; x=
	1724104265; bh=79SGA5Cc95BS0weDXk2zia6tb8xuQf9wB9eBRNR+CIU=; b=v
	SYBPStfNdE3IoA2l9aiHNGf5MA67a3FLI4ggum350qTO/0x+Pg1qMYhzznrmlMfz
	Z3Kj3uHpsoUx7yzMTURGPiIjoEERIjur9/qNSXJA3mK4YhKyLKJellq+NM3XYzW9
	WJK5YWq+ub5abzjPa8DAmkEpZUG9Uwsr+BtyK1eA9KxmqdzHcxA/+y5m8bQwjO1c
	JmM4P7MKDZpGfyd8MvpVFVSP2eiBRseuhMI0M4RBKFS7Ge9rhe85gHMC7QjwE9Dh
	2eSF7KcGiQgbv+UKRBYenHz3quzn9WcyYiN9eJZoHTLD1hCcgW0DbQK4oUzuCeou
	OiEFF9hM7UqZbJXBeCI5g==
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=
	messagingengine.com; h=cc: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-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=
	fm3; t=1724017865; x=1724104265; bh=79SGA5Cc95BS0weDXk2zia6tb8xu
	Qf9wB9eBRNR+CIU=; b=eLvvcZF08tOZfsELrLYnoUFvsZgpLq8nWPfZQf2NcLU+
	7K1Iyvu5VK8RZUBkdXAT3TeO3btzWO+vAImnhRaggLiLiGnq2/0XKhsSMrtzlZW5
	bAvvcPwBMOcz8fwCJodO32xUxbIWo38bcEn0+2xstaGOBl49Fyy2Ag0Uod+JLKDL
	+5haqBFVmKqX2f6rgO5QXIBHSkjLfe19jEmACmxX9Idv2HVdEBO8J/pUFUKztmqX
	n3XwqGFOeTXFwLaJabCpJ0uupeH8rsEsnzdKtvhHQjTLJb+wv4dy6V1t6aHYzKjN
	WC33vFkwmlK3uFMeW6FzmRNdB0onaEwhP59FFb1+Ow==
X-ME-Sender: <xms:yGzCZuDCsjCGgzIA4MAfW-xRJTs_ZPCXWYqSApca9y0RYOk4RA3UnQ>
    <xme:yGzCZohVqIWhn5CxCdYOw1mW5O3G664gMnJAxg0QDTSCKw6vCrZIhCKadvgq6HrqE
    I9DVmNTTYGhCCSmGrI>
X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeeftddruddufedgtdefucetufdoteggodetrfdotf
    fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdggtfgfnhhsuhgsshgtrhhisggvpdfu
    rfetoffkrfgpnffqhgenuceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnh
    htshculddquddttddmnecujfgurhepofggfffhvfevkfgjfhfutgesrgdtreerredtjeen
    ucfhrhhomhepfdftohgsucfnrghnuggvrhhsfdcuoehrohgssegsohhtthhlvggurdgtoh
    guvghsqeenucggtffrrghtthgvrhhnpeffgeevveegtdffgfffvdfftddvheeuleegveek
    teffueeliedtgeekjeettdetkeenucffohhmrghinhepphhhphdrnhgvthenucevlhhush
    htvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpehrohgssegsohhtthhl
    vggurdgtohguvghspdhnsggprhgtphhtthhopedvpdhmohguvgepshhmthhpohhuthdprh
    gtphhtthhopehphhhpqdhlihhsthhssehkohgrlhgvphhhrghnthdrtghomhdprhgtphht
    thhopehinhhtvghrnhgrlhhssehlihhsthhsrdhphhhprdhnvght
X-ME-Proxy: <xmx:yGzCZhnzROb8dW34nv1mwltnumvVs2avDQG4xfgCqhSDCFGAugxJgg>
    <xmx:yGzCZsxjswu0TpSBZdFAjmrjXw7rmi69smBbnuU1qMXCPPJEl9cgDA>
    <xmx:yGzCZjSKXksPoqpw7vKaylZtmGz_LQkGVwDyPWIfzUZkgJoDNfnHyQ>
    <xmx:yGzCZnYsQgi4x0Mu9BPESbKK05g1tITsqe7w5NO80TE3EwxPrLca9Q>
    <xmx:yWzCZqKc7igdwtMXQMdYZAa1XCka_8aWAZ7bLU2b-xwmQClB9lZtJ5C7>
Feedback-ID: ifab94697:Fastmail
Received: by mailuser.nyi.internal (Postfix, from userid 501)
	id 6BBEB15A005E; Sun, 18 Aug 2024 17:51:04 -0400 (EDT)
X-Mailer: MessagingEngine.com Webmail Interface
Precedence: bulk
list-help: <mailto:internals+help@lists.php.net
list-unsubscribe: <mailto:internals+unsubscribe@lists.php.net>
list-post: <mailto:internals@lists.php.net>
List-Id: internals.lists.php.net
x-ms-reactions: disallow
MIME-Version: 1.0
Date: Sun, 18 Aug 2024 23:50:43 +0200
To: "Stephen Reay" <php-lists@koalephant.com>
Cc: "PHP internals" <internals@lists.php.net>
Message-ID: <6cc30222-5636-48a6-be67-622954d42e86@app.fastmail.com>
In-Reply-To: <44486322-F313-405C-91D0-EA13FCAD9C65@koalephant.com>
References: <a897e9e9-dcc7-47f9-86db-c3c15294046a@app.fastmail.com>
 <94259551-80EE-41F4-9CF9-679B79B5EA49@koalephant.com>
 <c7782917-55ce-4d5b-bfad-2048d9a0af2d@app.fastmail.com>
 <44486322-F313-405C-91D0-EA13FCAD9C65@koalephant.com>
Subject: Re: [PHP-DEV] function autoloading v4 RFC
Content-Type: multipart/alternative;
 boundary=19fcce9433be45408496ba85f6458830
From: rob@bottled.codes ("Rob Landers")

--19fcce9433be45408496ba85f6458830
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: quoted-printable

On Sun, Aug 18, 2024, at 11:36, Stephen Reay wrote:
>=20
> Hi Rob,
>=20
>> On 18 Aug 2024, at 04:33, Rob Landers <rob@bottled.codes> wrote:
>>=20
>> I wouldn't consider it a BC break, no. But (ironically?), Symfony cra=
shes with this change.
>=20
>=20
> I wasn't aware of that specific code before but it's exactly the type =
of issue I was talking about earlier.
>=20
>> Ah, good catch. I've updated this and gone through other relevant fun=
ctions.
> The RFC now says "The spl_autoload function will not be updated.", but=
 that will *also* break if it isn't updated to at least *account for*, e=
ven if it doesn't *use* the second argument given.
>=20
> However I'm also curious why you would *specifically* make it *not* su=
pport function loading?
> The current implementation should work unmodified, once the signature =
is changed to accept an int as the second parameter (and move the curren=
t 2nd parameter to 3rd),  There is nothing "class specific" in the exist=
ing implementation except for a couple of variable names.
>=20
>=20
> I would imagine you also need to update spl_autoload_unregister[1] - i=
t also needs to be able to identify the type of autoloader it's operatin=
g on (because the same autoloader might be defined for both types).
>=20
> And lastly I think you'd need to adapt spl_autoload_functions[2] too -=
 perhaps the same as the others, introduce a parameter `int $type =3D SP=
L_AUTOLOAD_CLASS`, so existing code works as-is, otherwise it'd be impos=
sible to know how a given autoloader was registered.
>=20
>=20
> 1: https://www.php.net/manual/en/function.spl-autoload-unregister.php
> 2: https://www.php.net/manual/en/function.spl-autoload-functions.php
>=20
>=20
> Cheers
>=20
> Stephen=20

Hello again internals,

The implementation has now reached a stable point and things discovered =
during the implementation have been reflected in the RFC text itself.

I did my best to assess the impact to Opcache, but I suspect someone muc=
h more familiar with how opcache works will need to take a look. From my=
 understanding of the changes needed in zend_execute, it looks like ther=
e are some changes needed to the JIT helpers, but there may be more chan=
ges required that aren't so obvious. I've added a helper that can be use=
d as a drop-in replacement for looking up functions from the function ta=
ble directly, which should help.

Lastly, I do plan to open a docs PR in the coming week that will probabl=
y trigger some smaller updates to the RFC; mostly to smooth out the word=
ing and make it more friendly for non-technical people, but the technica=
l aspects shouldn't change (barring the discussion here, of course).

> The RFC now says "The spl_autoload function will not be updated.", but=
 that will *also* break if it isn't updated to at least *account for*, e=
ven if it doesn't *use* the second argument given.

I've updated the text to reflect exactly that, it did require updating. =
;)

> However I'm also curious why you would *specifically* make it *not* su=
pport function loading?
> The current implementation should work unmodified, once the signature =
is changed to accept an int as the second parameter (and move the curren=
t 2nd parameter to 3rd),  There is nothing "class specific" in the exist=
ing implementation except for a couple of variable names.

I mostly decided not to support it to avoid the inevitable bikeshedding =
of how a "default function autoloader" would work. I really want to push=
 that to a separate RFC, unless there was a general consensus of an impl=
ementation. If we are fine reusing the existing default class autoloadin=
g, then I am fine with that.

> And lastly I think you'd need to adapt spl_autoload_functions[2] too -=
 perhaps the same as the others, introduce a parameter `int $type =3D SP=
L_AUTOLOAD_CLASS`, so existing code works as-is, otherwise it'd be impos=
sible to know how a given autoloader was registered.

I've also added those functions as well.

=E2=80=94 Rob
--19fcce9433be45408496ba85f6458830
Content-Type: text/html; charset=utf-8
Content-Transfer-Encoding: quoted-printable

<!DOCTYPE html><html><head><title></title><style type=3D"text/css">p.Mso=
Normal,p.MsoNoSpacing{margin:0}</style></head><body><div>On Sun, Aug 18,=
 2024, at 11:36, Stephen Reay wrote:<br></div><blockquote type=3D"cite" =
id=3D"qt" style=3D"overflow-wrap:break-word;"><div><br></div><div><div s=
tyle=3D"color:rgb(0, 0, 0);">Hi Rob,<br></div><div><br></div><blockquote=
 type=3D"cite"><div>On 18 Aug 2024, at 04:33, Rob Landers &lt;rob@bottle=
d.codes&gt; wrote:<br></div><div><br></div><div><span style=3D"font-styl=
e:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;=
text-align:start;text-indent:0px;text-transform:none;text-wrap:wrap;word=
-spacing:0px;-webkit-text-stroke-width:0px;text-decoration-line:none;tex=
t-decoration-thickness:initial;text-decoration-style:initial;text-decora=
tion-color:initial;float:none;display:inline !important;"><span class=3D=
"font" style=3D"font-family:Helvetica;"><span class=3D"size" style=3D"fo=
nt-size:12px;">I wouldn't consider it a BC break, no. But (ironically?),=
 Symfony crashes with this change.</span></span></span><br></div></block=
quote></div><div><br></div><div><br></div><div>I wasn't aware of that sp=
ecific code before but it's exactly the type of issue I was talking abou=
t earlier.<br></div><div><br></div><div><div><blockquote type=3D"cite">A=
h, good catch. I've updated this and gone through other relevant functio=
ns.<br></blockquote></div></div><div>The RFC now says "The spl_autoload =
function will not be updated.", but that will *also* break if it isn't u=
pdated to at least *account for*, even if it doesn't *use* the second ar=
gument given.<br></div><div><br></div><div>However I'm also curious why =
you would *specifically* make it *not* support function loading?<br></di=
v><div>The current implementation should work unmodified, once the signa=
ture is changed to accept an int as the second parameter (and move the c=
urrent 2nd parameter to 3rd), &nbsp;There is nothing "class specific" in=
 the existing implementation except for a couple of variable names.<br><=
/div><div><br></div><div><br></div><div>I would imagine you also need to=
 update spl_autoload_unregister[1] - it also needs to be able to identif=
y the type of autoloader it's operating on (because the same autoloader =
might be defined for both types).<br></div><div><br></div><div>And lastl=
y I think you'd need to adapt spl_autoload_functions[2] too - perhaps th=
e same as the others, introduce a parameter `int $type =3D SPL_AUTOLOAD_=
CLASS`, so existing code works as-is, otherwise it'd be impossible to kn=
ow how a given autoloader was registered.<br></div><div><br></div><div><=
br></div><div>1:&nbsp;<a href=3D"https://www.php.net/manual/en/function.=
spl-autoload-unregister.php">https://www.php.net/manual/en/function.spl-=
autoload-unregister.php</a><br></div><div>2:&nbsp;<a href=3D"https://www=
.php.net/manual/en/function.spl-autoload-functions.php">https://www.php.=
net/manual/en/function.spl-autoload-functions.php</a><br></div><div><br>=
</div><div><br></div><div>Cheers<br></div><div><br></div><div>Stephen&nb=
sp;<br></div></blockquote><div><br></div><div>Hello again internals,<br>=
</div><div><br></div><div>The implementation has now reached a stable po=
int and things discovered during the implementation have been reflected =
in the RFC text itself.<br></div><div><br></div><div>I did my best to as=
sess the impact to Opcache, but I suspect someone much more familiar wit=
h how opcache works will need to take a look. From my understanding of t=
he changes needed in zend_execute, it looks like there are some changes =
needed to the JIT helpers, but there may be more changes required that a=
ren't so obvious. I've added a helper that can be used as a drop-in repl=
acement for looking up functions from the function table directly, which=
 should help.<br></div><div><br></div><div>Lastly, I do plan to open a d=
ocs PR in the coming week that will probably trigger some smaller update=
s to the RFC; mostly to smooth out the wording and make it more friendly=
 for non-technical people, but the technical aspects shouldn't change (b=
arring the discussion here, of course).<br></div><div><br></div><blockqu=
ote type=3D"cite" id=3D"qt" style=3D"overflow-wrap:break-word;"><div>The=
 RFC now says "The spl_autoload function will not be updated.", but that=
 will *also* break if it isn't updated to at least *account for*, even i=
f it doesn't *use* the second argument given.<br></div></blockquote><div=
><br></div><div>I've updated the text to reflect exactly that, it did re=
quire updating. ;)<br></div><div><br></div><blockquote type=3D"cite" id=3D=
"qt" style=3D"overflow-wrap:break-word;"><div>However I'm also curious w=
hy you would *specifically* make it *not* support function loading?<br><=
/div><div>The current implementation should work unmodified, once the si=
gnature is changed to accept an int as the second parameter (and move th=
e current 2nd parameter to 3rd), &nbsp;There is nothing "class specific"=
 in the existing implementation except for a couple of variable names.<b=
r></div></blockquote><div><br></div><div>I mostly decided not to support=
 it to avoid the inevitable bikeshedding of how a "default function auto=
loader" would work. I really want to push that to a separate RFC, unless=
 there was a general consensus of an implementation. If we are fine reus=
ing the existing default class autoloading, then I am fine with that.<br=
></div><div><br></div><blockquote type=3D"cite" id=3D"qt" style=3D"overf=
low-wrap:break-word;"><div>And lastly I think you'd need to adapt spl_au=
toload_functions[2] too - perhaps the same as the others, introduce a pa=
rameter `int $type =3D SPL_AUTOLOAD_CLASS`, so existing code works as-is=
, otherwise it'd be impossible to know how a given autoloader was regist=
ered.<br></div></blockquote><div><br></div><div>I've also added those fu=
nctions as well.<br></div><div><br></div><div id=3D"sig121229152">=E2=80=
=94 Rob<br></div></body></html>
--19fcce9433be45408496ba85f6458830--