Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:129867 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 067C31A00BE for ; Thu, 22 Jan 2026 16:42:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1769100137; bh=58B7xkpcuA5r51DKiFNNJsHiw8yQP7Xi8NdPdcQhA6Y=; h=References:In-Reply-To:From:Date:Subject:To:From; b=lh3CQCzuAHI48jFjBkZVIsu7XQscarJJMCyddIAmIV01PuM1PUMlQtrvTP2DxvFwy PZ8zmhMJAI9YQARXCizIJR2/aKyvdYndbqykrLD6TKDyBQgKZs609b47QLNTd/3kfW puwoO/ARSicorCDQwsnRLYxxs774g3Bd44HPO7JZhDKVdBj12ic42Ebfa4mSKD73XH rNRS+IEm1KdxyrK5feZQS3ec6cEoWtqDG50KqujV07WolYtCXkee2SukTJWnvhgaYh ZqeOccPzRnllmK1gtx9wlz7qmCQi5Gk/+kM7orqn/x2vEN+Im9CLVk+vTyDy0Mjbiy RJjLjpb2SD9AQ== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 18F331805AD for ; Thu, 22 Jan 2026 16:42:15 +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.6 required=5.0 tests=ARC_SIGNED,ARC_VALID,BAYES_50, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,DMARC_PASS, FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE, SPF_PASS autolearn=no autolearn_force=no version=4.0.1 X-Spam-Virus: No X-Envelope-From: Received: from mail-qk1-f182.google.com (mail-qk1-f182.google.com [209.85.222.182]) (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 16:42:12 +0000 (UTC) Received: by mail-qk1-f182.google.com with SMTP id af79cd13be357-8c6a0702b86so117341585a.0 for ; Thu, 22 Jan 2026 08:42:07 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1769100127; cv=none; d=google.com; s=arc-20240605; b=KhrLRPhleLnIlSi3RdCRQiX1eKxYlMFFqVhGOlKub4+Eo4clLEghXxLAfLiU0BAvnY 8xlU/OisOT5nMFWWMbf6LjaHePfpvggjVTa5zZOTbyuVgfgsQCe4hahC5V63feQGWGl4 KKoTI26teiTrFKgJbNr/U4uhnm/KNaj78mY04IOLJ4omYnw4BUzzgQYTPCCusXasLFbE 4t/RPpGPlif38V1NG1aexAJ9lWRZ69XR+tJ0Rmk9hznUELsyCt99+iYIjOajXTOffX2m XZhCgX2t6D1/6Q0drJ9tofDSvKv+Yze8OGpU7wCjtNCc29PLR3CAgCWHFyLDXHRlNycn 4ugg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=content-transfer-encoding:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=+2TRMO3SveXhPq/2PTjAcmQ4XCOYUUplf2ZJVj6RFCM=; fh=RnZ+4KjfdZdxwVfzmjFoBvUAaJ227RJecqE9MM9tvfQ=; b=er8AWo4FUz6/D3Vr3MPBM7HFO51pvc6TupxWTyEzRMW//VKy+Veg4gIvPg26V2GPZJ IO1jf30vDHVaylJJET8EC/tTyukp7Q2tzpFn/ZUZc/o4y+VKq42GSmeFV5tLqgHCdgZH r02r7b/lq7CJFOLJY++U6s0DwykaJ9/YhDYMWQGXw6zrT1WgMGfkF9p/jTN15BX/EKZC w1ClbLWKG47ULjC3RnM1DV/6gTZuMruDYjnn/83VVBSdO3nsQoiMt5djt1YcQiKqqfKc 1aqe03fx7JRg5Yb0okY058l/tl1xz+X6+WGmGdQkOjRzNKZz/RBU4R7YAmB5tNprTOP9 X3dQ==; darn=lists.php.net ARC-Authentication-Results: i=1; mx.google.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1769100127; x=1769704927; darn=lists.php.net; h=content-transfer-encoding:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=+2TRMO3SveXhPq/2PTjAcmQ4XCOYUUplf2ZJVj6RFCM=; b=BpoD7kgzepCvSr94Sq75oAEbVupS2vJUXro/XQRftyR9RcB24Gi12RNP65lWeV1sx7 32B7L2ylMnBXqNcx5Bh6FlcJ+6OVo5ZaP+Bqsd+iEaql5U9XNzMcg4niRJkLBRjFuZ9Y HVIK//90iT0cDwhnnrGsCMLO7ykIQeMl5Sk2AAZBOHzvc70AGSGFtOPi6gOMHuawdrHu QJ0m3h1S8Xv8xhku+MsDB2SXWF8mB6an5WnxlHLYqlthhpW2jWBGzSZwHnSifq7KxBED 7Vp0gQ1zni9FnB+WWW4ObRXFmNlu/CHsTGpPJVf4S3oMBfu7erDAFOkUre9SPgRrfhlR /FMA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1769100127; x=1769704927; h=content-transfer-encoding:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=+2TRMO3SveXhPq/2PTjAcmQ4XCOYUUplf2ZJVj6RFCM=; b=nYIBneQYYrmEvsaiqB/y+t9di8Ma1VijfVqLbLXcWQKjzhQVXsL+TfCT/wn7B/lnfp Z7vBc7f8EUdF6NtYqfpzbDepwksLbhc8TBIN/U2HplrVP7TO0nUBgXjh9SI+vAhV33SF MftTwNRcJy7WSGlV7vW7tTt402p1EvLhpjdKzJMW82ixE7ZNTi5LmAY9MgrlmoIHKmf8 WX7l4XZyfV0j4fAyQMZmXybk1ywnLMVioHVvMV+87vl+o1RIDjIQhuR9WeeO/K9MgxfW w/B5ZI7Cl9l5h4rCCX2D+XG3mzaIDEVmFfIjg6N89brIUCmpb/S7vvWbUDaMyiXthNrl b7Xg== X-Gm-Message-State: AOJu0YxtbcFz8wyrIYw5XE/fqZ7+4jPGF+wXhEpgHSVvnlCCh8hP1Ehr fls7kJYexMYml4goCOwhZgkdjsSfaEzdmOsW3Gd7BXcXMKpy1GQrxyAYpabq3uNmLtHsrWvv1Be AG2EHKKxp6oIxQj886PWl8ke+xIfI8nH4nhu5+54= X-Gm-Gg: AZuq6aJBDsIKF/r/ITWMtmY50MFdRDuVRwdfGsasVbcR726bDo74udgiTzPOULoyGrV zrg47Bw37uEXr2xN0rxqWNubXhSdoDE+Ltwxy1y6mIjafq2FhcA4P/vbfqCbMwYyyEH34JZQH9B 7N2rN9M1Bsafs05OgicdGUlc/cBvJCuAaj/sQxIbPnyXLs7EaeFzzy6Kj0uUhgtRnxiyJv4zSrI UlXrEEOmMxGLyAuhSJ1dNOhjHgnIsYhbJsW8Pt610AX/fslInnnO/PR3j317v/pCvnyReikH5MO I59MIFUL4vS+8tyMKFMIhtx/fpd3Zg== X-Received: by 2002:a05:620a:4708:b0:8b2:dbc0:a1e3 with SMTP id af79cd13be357-8c6e2d7d3d5mr7264485a.15.1769100126556; Thu, 22 Jan 2026 08:42:06 -0800 (PST) Precedence: list list-help: list-unsubscribe: list-post: List-Id: x-ms-reactions: disallow MIME-Version: 1.0 References: In-Reply-To: Date: Thu, 22 Jan 2026 17:41:55 +0100 X-Gm-Features: AZwV_Qij9sdIwaFdKGn9Es3ojknhV35dzf1BKaRcI4vcucS6XLbcQr_3M1yJk-s Message-ID: Subject: Re: [PHP-DEV] Closure optimizations To: php internals Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable From: tovilo.ilija@gmail.com (Ilija Tovilo) 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, this > > 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 mentions, a= s they seem to be accurate anyway. > > My one question is about the bindTo() on an inferred static closure. Wha= t 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 ge= t what value bindTo() would have. What's the use case for making an except= ion 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