Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:125112 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 7CE6A1A00BD for ; Fri, 23 Aug 2024 09:14:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1724404554; bh=sBLkdSgOEvY7tErkeddGybNe8f2tcxYY+/U3A/sa5hw=; h=Date:From:To:In-Reply-To:References:Subject:From; b=MxhSC80oD/nwWh716nVcliBKDLxCjKvVJEpdyj6pAbvMyXjE32rY2fdK1uG/ekD0i DWWEAOTq2IZRHVv6lPhzmbU3y6R3D93shX5bNW6O8YAjszWgAPZlaOwCKq6r8Ahios /uBVtLZ9wjiPjg5CNEYDaFbpg/9XlRZHi5CTFoxFc9KtqD1UfCdbihMuvc8MJDWxfm 3+YbB4UPo1RupuyE4V2M/e8H59fhidYySMFpaOhxd9r65SgWp0HkWnu83ug5WV2fz4 H2WFbp58MftogDhekOMAt1xFUASHYuS/AaPmCSqJ8B1fOLPK7BliYoJWAL4JQLWuEK CEzztTTqTAk+g== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 223EB180034 for ; Fri, 23 Aug 2024 09:15:53 +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,RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL,SPF_HELO_PASS, SPF_PASS autolearn=no autolearn_force=no version=4.0.0 X-Spam-Virus: No X-Envelope-From: Received: from fout7-smtp.messagingengine.com (fout7-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)) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Fri, 23 Aug 2024 09:15:52 +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 1F7EE138FFE6 for ; Fri, 23 Aug 2024 05:14:01 -0400 (EDT) Received: from phl-imap-09 ([10.202.2.99]) by phl-compute-03.internal (MEProxy); Fri, 23 Aug 2024 05:14:01 -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=fm2; t=1724404441; x=1724490841; bh=tX8ZiXNbiZ qmsiSmnBvNZ+r7PtAcXFykL4hPK5QreV4=; b=cf4nhZNmuBBmgV3Zq3Lsd6HEnU MXjQHsvAKono/H+2LJwFRupt6IrAqQi60i/DJyU8nteZ7Tlx6X79yIMACwOvW07A 4z6FpfS110Kl4gOVcOkagcr2LtAobutVgK3i0WHmHjLpE7qKeafvZaz460rMA6QE P9Zy7DjlsHagQG4LeMOhrOlAas82Ng4KArr9yXfmizCa6Zfg6k+7eiU4T3Qza6KT +mMgLCYcCd3GktxCbdtWQv980v4enZKUSv1axbdIO3do34+qwsW76vMjyoxSMVUk wybp4hXgf1hnWlXr+h/5kq2XiS/F1PWwTgnhwlffE8Dx6i5gD8h1V0PGIMcg== 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-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm1; t=1724404441; x=1724490841; bh=tX8ZiXNbiZqmsiSmnBvNZ+r7PtAc XFykL4hPK5QreV4=; b=S7HGLtSN3GzVfTAitjHHywDDwfalJuaAZXVwsu1RA23K c+VGHtCiS3a7eZP03rBfM+ifUs2SF8f7NYNIXwzWb9IaeTZnkDjOPfiYbU008Bsj Pey12uBbQDhPsive13NM2wssIFiw8a65ULSoYtFz+PD9Cf437RJ8U+Odpr2exCP2 M5Y8hdDsScN18kaWnRFheJPSVJ+qfdahY5VI2gBAVM6QbVojEoWP+eLIlP5FGksW wd/8WG8kZG/LUAiczTZS218gY/sdXBhdytrSBznQmZo5ax/guzh0K2RAUoR+vbrf yyUoevVEu2v2sUCgHzxcrtZDKJy2y2L5EGe5HpnONg== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeeftddruddvvddguddvucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdggtfgfnhhsuhgsshgtrhhisggvpdfu rfetoffkrfgpnffqhgenuceurghilhhouhhtmecufedttdenucenucfjughrpefoggffhf fvkfgjfhfutgesrgdtreerredtjeenucfhrhhomhepfdftohgsucfnrghnuggvrhhsfdcu oehrohgssegsohhtthhlvggurdgtohguvghsqeenucggtffrrghtthgvrhhnpedtueejtd ethfeulefhtdelieduteelffdtudelheffgedtieehhfelieejgfevgeenucevlhhushht vghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpehrohgssegsohhtthhlvg gurdgtohguvghspdhnsggprhgtphhtthhopedupdhmohguvgepshhmthhpohhuthdprhgt phhtthhopehinhhtvghrnhgrlhhssehlihhsthhsrdhphhhprdhnvght X-ME-Proxy: Feedback-ID: ifab94697:Fastmail Received: by mailuser.nyi.internal (Postfix, from userid 501) id 912B3780065; Fri, 23 Aug 2024 05:14:00 -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 Date: Fri, 23 Aug 2024 11:13:39 +0200 To: internals@lists.php.net Message-ID: In-Reply-To: References: <846D7756-712B-4A7C-9FC6-DB9F858836B8@rwec.co.uk> <880ffc27dc9b421407a670c75d5f5ba756870396.camel@ageofdream.com> <790534cd-e158-4712-878c-642dfd0e2bad@app.fastmail.com> Subject: Re: [PHP-DEV] [Concept] Flip relative function lookup order (global, then local) Content-Type: multipart/alternative; boundary=ccf354d2f16345278164b3e19537d691 From: rob@bottled.codes ("Rob Landers") --ccf354d2f16345278164b3e19537d691 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On Fri, Aug 23, 2024, at 10:08, Nick Lockheart wrote: >=20 > >=20 > > If we were to go with any major change in the current lookup where it > > is perf or nothing, this is what I would propose for php 9.0 > > (starting with an immediate deprecation): > > 1. any unqualified call simply calls the current namespace > > 2. >=3D php 9.0: no fallback to global > > 3. < php 9.0: emit deprecation notice if falls back to global > > This is how classes work (pretty sure), so it would be consistent. > >=20 > > Going the other way (global first) doesn't really make sense because > > it is inconsistent, IMHO. Will it suck? Probably. Will it be easy to > > fix? Probably via Rector. > >=20 > > =E2=80=94 Rob >=20 >=20 > A third option, which I haven't seen come up on the list yet, is that > unqualified functions that are PHP built-ins are treated as global, and > using a function having the same name as a built-in, in a namespace > scope, requires a fully qualified name to override the built-in. >=20 > It seems that if someone is writing `array_key_exists()` or similar > they probably mean the built-in function, and in the rare cases where > they do mean `\foo\array_key_exists()`, they can write it explicitly. >=20 > Functions that are *not* on the built-in function list could default to > the local namespace. I was actually thinking of doing something like this for function autolo= ading, where extensions could register global functions that bypass the = autoloader and go straight to global if it isn't defined in the local na= mespace already. I decided not to even bring it up because it felt contr= oversial (it would effectively be global first, except for user function= s). Though, it might be a nice compromise? =E2=80=94 Rob --ccf354d2f16345278164b3e19537d691 Content-Type: text/html; charset=utf-8 Content-Transfer-Encoding: quoted-printable
On Fri, Aug 23,= 2024, at 10:08, Nick Lockheart wrote:


>= If we were to go with any major change in the current lookup where it
> is perf or nothing, this is what I would propose for p= hp 9.0
> (starting with an immediate deprecation):
<= /div>
>    1. any unqualified call simply calls th= e current namespace
>    2. >=3D php = 9.0: no fallback to global
>    3. < = php 9.0: emit deprecation notice if falls back to global
&= gt; This is how classes work (pretty sure), so it would be consistent.

> Going the other way (global f= irst) doesn't really make sense because
> it is inconsi= stent, IMHO. Will it suck? Probably. Will it be easy to
&g= t; fix? Probably via Rector.

>= =E2=80=94 Rob


A third optio= n, which I haven't seen come up on the list yet, is that
u= nqualified functions that are PHP built-ins are treated as global, and
using a function having the same name as a built-in, in a n= amespace
scope, requires a fully qualified name to overrid= e the built-in.

It seems that if someone is= writing `array_key_exists()` or similar
they probably mea= n the built-in function, and in the rare cases where
they = do mean `\foo\array_key_exists()`, they can write it explicitly.

Functions that are *not* on the built-in function = list could default to
the local namespace.

I was actually thinking of doing something li= ke this for function autoloading, where extensions could register global= functions that bypass the autoloader and go straight to global if it is= n't defined in the local namespace already. I decided not to even bring = it up because it felt controversial (it would effectively be global firs= t, except for user functions). Though, it might be a nice compromise?

=E2=80=94 Rob
--ccf354d2f16345278164b3e19537d691--