Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:129869 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 BDA5C1A00BC for ; Thu, 22 Jan 2026 17:19:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1769102345; bh=pgGzCV7S3lKxRN/PVEwng/0HpJD55dC7oqLOW72f+b4=; h=Date:From:To:In-Reply-To:References:Subject:From; b=RbvVajSUUh1xTr9izwX3eCU9j8m0fAkgBxbHTVmEJdJSc2Bb47iQkMq8pHkG6UMkq su+hesqECe3ndTB8LEip7KVeeupEKMbVUqFCMXkHkmZ1oUV8byfcKzZ0NxI13B+++f q2hGneO6S/GfHTW8F6oqff4JWZqmBstxfWGJeN+ibGUNbpfGnJiJy/Y8HP91Mgcc/Z oud1sU66mG7zCq3Fy+Rxk9jntq3tLTONWJ/c50D994JBJUnPNJzP0V0uRKsmW9T6ij mlHWf15vDt0fJJUSeShBTIihOHvaQwUVKj93Bmu0M46wz/PbcAhPQvte33xUk5gwM4 ARsEn/LQgnoiQ== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id B13591804BC for ; Thu, 22 Jan 2026 17:19:04 +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_NONE autolearn=no autolearn_force=no version=4.0.1 X-Spam-Virus: No X-Envelope-From: Received: from fhigh-b3-smtp.messagingengine.com (fhigh-b3-smtp.messagingengine.com [202.12.124.154]) (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 ; Thu, 22 Jan 2026 17:18:54 +0000 (UTC) Received: from phl-compute-04.internal (phl-compute-04.internal [10.202.2.44]) by mailfhigh.stl.internal (Postfix) with ESMTP id 01FEB7A0151 for ; Thu, 22 Jan 2026 12:18:48 -0500 (EST) Received: from phl-imap-02 ([10.202.2.81]) by phl-compute-04.internal (MEProxy); Thu, 22 Jan 2026 12:18:49 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= garfieldtech.com; 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=fm2; t=1769102328; x=1769188728; bh=77Z0R4C/Pqw0iSfBDl5yO 6skUzxUqF83GLVTW2aOXho=; b=PMOHjx83MC+ffisTm07bvgmJXVu4YPX0CdsYE uTCFgt1dLHOaH0MG6R3q9YnxB223gqGa3DbioziFjDYndY2Srw8HUAgnAUFwp1Xx VXfEJJ8fcO3B/TqwOCSRiQSN5tUjZnEznj2ObnXY+BYgWWpzS4QEyMi0/QnLkReJ lKbslT2zPJ7o5j7VeiKsJtaZSAHRe+e4u14xS69t5xa/qHq9U1zCAKk4EAA28JpJ 05Y6zTywEytLe11smgd6iSW5NAEBQgsrO02R9pEIdfYV5YFjblW/DHFOcxnLZsdK OLU8cWNXSskm4raIsbxtKEVcBlYuCm2M/KeXpCcBDdoqkcuyQ== 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=fm2; t=1769102328; x=1769188728; bh=7 7Z0R4C/Pqw0iSfBDl5yO6skUzxUqF83GLVTW2aOXho=; b=Fh3tOZhrmkSmeKT3n gY7QZS7nUD1ehy2rA5diTtnyf2RZEX7ds1m6aO3zvNBPsqVDAHzAjkTnD01OO0q5 3Q87pUZxu9eFFgbSQzbZWPrZONnQ6FUGM66jivrReEs55POvOaU8LlbAHtu3/lMH U+58PrcYvj48b3poZKxeogzFWrdc2Voy7BOaySuIUgglLAull7BIDba83KQZOnJi IkVxLZLwGcymdSFB4Xu0FDOhKREFBL+c9NsYfbUiRnrLqXB2VSRU4Lo3GFMcxFsP rpCs4HXSlTCAKKDJtpZFe+H1kjRXSvNI5zvVcFB/Xdot2GAhdhObA/qXNyL0vHjy r6KYw== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefgedrtddtgddugeeijeegucetufdoteggodetrf dotffvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfurfetoffkrfgpnffqhgenuceu rghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmnecujf gurhepofggfffhvffkjghfufgtgfesthhqredtredtjeenucfhrhhomhepfdfnrghrrhih ucfirghrfhhivghlugdfuceolhgrrhhrhiesghgrrhhfihgvlhguthgvtghhrdgtohhmqe enucggtffrrghtthgvrhhnpeehvdetvefggeekffdvheektdekvedvhedvvdfhgfdtleei veeigfetieeggeevteenucffohhmrghinhepghhithhhuhgsrdgtohhmpdefvheglhdroh hrghenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpehl rghrrhihsehgrghrfhhivghlughtvggthhdrtghomhdpnhgspghrtghpthhtohepuddpmh houggvpehsmhhtphhouhhtpdhrtghpthhtohepihhnthgvrhhnrghlsheslhhishhtshdr phhhphdrnhgvth X-ME-Proxy: Feedback-ID: i8414410d:Fastmail Received: by mailuser.phl.internal (Postfix, from userid 501) id 9D9A7700065; Thu, 22 Jan 2026 12:18:48 -0500 (EST) X-Mailer: MessagingEngine.com Webmail Interface Precedence: list list-help: list-unsubscribe: list-post: List-Id: x-ms-reactions: disallow MIME-Version: 1.0 X-ThreadId: ARzF8cVOtAfV Date: Thu, 22 Jan 2026 11:18:28 -0600 To: "php internals" Message-ID: <7562c18a-e0e4-4af5-aca1-bea0a7078c7b@app.fastmail.com> In-Reply-To: References: Subject: Re: [PHP-DEV] Closure optimizations Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable From: larry@garfieldtech.com ("Larry Garfield") On Thu, Jan 22, 2026, at 10:41 AM, Ilija Tovilo wrote: > Hi Larry > > On Thu, Jan 22, 2026 at 5:03=E2=80=AFPM Larry Garfield wrote: >> >> On Wed, Jan 21, 2026, at 1:52 PM, Ilija Tovilo wrote: >> > >> > I've created a PR implementing two new optimizations for closures. = [1] >> > There are some theoretical BC breaks, so please let me know if any = of >> > them are of concern to you. >> > >> > Of note is that Closure::bind() and Closure::bindTo() usually throw >> > when attempting to bind an object to a static closure. In my PR, th= is >> > is explicitly allowed only for closures that are inferred as static, >> > but not those that are explicitly static. >> > >> > >> > [1] https://github.com/php/php-src/pull/19941 >> >> This all looks great, Ilija! I am not concerned about the BC mention= s, as they seem to be accurate anyway. >> >> My one question is about the bindTo() on an inferred static closure. = What purpose does that serve? I'm assuming that anything that mentions= $this in its body won't be marked static, and if it doesn't have $this = I don't get what value bindTo() would have. What's the use case for mak= ing an exception here? > > Oops, it seems I've left out some details I was meaning to add. The > aim for allowing the passing of objects to Closure::bind[To]() is to > retain BC when a closure can suddenly be inferred as static due to > seemingly unrelated changes. > > As mentioned, the rules for when static can be inferred are slightly > esoteric. For example, your code may be calling Foo::bar(), which > _looks_ like a static call, but could actually be an instance > grand-parent call (https://3v4l.org/uDi8W#v8.4.14). If you were to > remove this ambiguous call, and the closure could now be inferred as > static, it would be bad if existing Closure::bind[To]() calls would > break because they provide an object. For this reason, > Closure::bind[To]() will _accept but discard_ objects only for > closures inferred as static. > > Ilija Ah, so it's just a "don't break code that's already wrong but not harmfu= lly so" feature. I'm OK with that, but please add that to the RFC. --Larry Garfield