Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:130521 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 2163C1A00BC for ; Tue, 31 Mar 2026 14:04:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1774965854; bh=uSbOaP82P2yDzjCtigqGa1OIFeE3Y2v8UeNhEsu+N0Q=; h=From:Cc:Subject:Date:References:From; b=WaRmnYGD9wHeyHmZCguTSEhL+sL/PanXCk1xInFYZnCuquwY31FDCRPP2uUx6qPY9 wU5RxmtiWgW2rl98+WC0wOVXv8TWKetxH7WzOyrOlFoMd64mzXgLCYgaW0J1rmHPqd aFERK94hVu/8CPU5f8w3h1QwJMfnZxK3HeJZi1NHzuU3lfQCVJcHHg4aCTwxwcxSB8 QMIy0RDm8otVor4OVrw4GpNvTc3mZFua6BSDNj+INziBCFinq2OFvME0ppXibqs3G5 8r0VmHJluTMteuVOfdozCyQr6qkOPrD4a1bTkugvdmj11rEizUYS/H7k+IEnUg8t4Q fKpdUJrLqyJGg== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 917A81801EC for ; Tue, 31 Mar 2026 14:04:13 +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=1.6 required=5.0 tests=BAYES_50,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,DMARC_PASS,FREEMAIL_FROM, MISSING_HEADERS,SPF_HELO_PASS,SPF_PASS autolearn=no autolearn_force=no version=4.0.1 X-Spam-Virus: No X-Envelope-From: Received: from sonic.asd.mail.yahoo.com (sonic-euwe4-0022.asd.mail.yahoo.com [34.2.86.21]) (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 ; Tue, 31 Mar 2026 14:04:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.de; s=s2048; t=1774965846; bh=YkmGLYfRrZBJwDtVN0x9keNGi8SOE6lI6u3QZP7Vfg0=; h=From:Cc:Subject:Date:References:From:Subject:Reply-To; b=D2tOZ46Ae7PVPEqjvFpVuTSSHjqXQpMvUgy91gYVVbKXHwdDaftp0ofEfIdMCYwnQioMr9JSrNyJC7kXT7PWIF8cGbCT49t/nRNiL3sHW95VXc/MVC9VBVRCat4RUfIcM96ueWNB/uUEO30i0XCWYqFeLN9OAyfq3p8n72ZVTFT6suFmJQNwoviA7i9PfZPerQTkQo7HlB2cwmub2jsVtLxcrWEjBRgdDA4SUxRroo3ZkVgi78+CxUZCmXDBkvS08+ONOOXdGoOa0tXPUb8p214/FXnzloxC4vExMywgoeGJGjserinwbBe8akTpPGeSQO342CZMDvbzOXMwAbwQUQ== X-SONIC-DKIM-SIGN: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s2048; t=1774965846; bh=rGJla9wr8sqLfv5rlGtV5BJhNqjgcVk52HiOnwNjUrA=; h=X-Sonic-MF:From:Subject:Date:From:Subject; b=qzbSmmJjDCPPTKkBh2An91Ir0oTOXAkh4LhERgwubyqUnMriwV/wa47OoYTp1624sLy4ZAg8ZqnRQ3Bb/cwunEGkzQhWrFuRBGAnzcbD2bYak5mBN3M8G3X188qhPlsq6wxQjeIUY+4W+HpXrH6oozvCKKp3h1+T+Iz0afx8ck01JrtqEJzuPAqAirh4xHKAcr4cYfmHwgu2d6BNcnyxh0bdy0dokUVQo7OWVvRA+AijYojVwa/DlFZFs8EUnmAhcqeqJpCcaBpPTiLUO2hW/RbF4+tSoA4NjlkgnXe0EpGeho57rADScOOy1VZi9VGtBA0114ZZyimyo6VNvifvEA== X-YMail-OS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DSvXeCY1m_mkelfzL_WQUIe0NniAv8jPICCKjxtsKFr.owPseWUiD12fB5EsJrX5iO7_ hLLieM9muYdLKSIrStPoporprYaep.m.vdAjLFj_6zY2Nwt.N3HXrHrwY9YMT0yt67d6BkmBeqKO zQfOmf.Oyg.mFt52ZKIdOEzHxBLxUhqRFfyuZ2EJgfde.KeEvjuttN4EfNPzeO.Ipry4bJ6DVX65 z8.K3YDAixU_zGf_eNI.a_D4x2CqkN10qxlACFUvZkuz8lBiG2UjRfpLQT7BnWtrPJwlfqTVzgoM dwjvTsLrO5AghjaiWLwdazfHAlHjQLJ9kTZMk66VPYDXZYfHtIVoWkuEhTM5SfHapW9W45SqOpdI D.jDzjTCs1YZGpE.PFX2cM76lj.MmUT.pyjTQOgVtd3Pfyl251_KPiX.m9_E2J6c3V_mqgnP3UQu 5Kj06a_GGeoThkc0FeCo3wZSlVKa8LMB9hoXSkxNOp6IuBbFDpIisv8M6g79e_DyML0B5QwOIdwP HnbQXnawg1ktQIoTxP8tAc8WENAcU6707j4v8U7rzF7IAz6JqKu8.N4g0ci6ftTiYHdPjKDKTtV7 HU038m4TTBGiquFkBUnPIzk5uKTWNgKaJXyR6sD8veGIwyGFekwaDzLW8auTLR6Kb2p1JECcuZuW kbkdTPaeF0Xb4wLe3vVKPZ3hkcztWMyuQ39nxNzoX.RHfacR.aHScakgmxcLFjscCCe14rvEKyjJ HkTSY3X6IIsTXMVxeSwtWzTuzjzfYlB3fgWeQ2ZGRpFmzYmBVt2OJVW9ubOWanJf_l4HEAQ1KPEa R2c7BTD_9s2gUyUfpQqrXP7QnMQTKVg5y4XMrP2bbMhglIIR8qUti0ck4FVu7Valbc6zbx1kOYTZ rFGRnuiK1kp0CABmYMw-- X-Sonic-MF: X-Sonic-ID: b570e756-051f-4a02-b39f-7abb0cb39106 Received: from sonic.gate.mail.ne1.yahoo.com by mail-asdoutdeli-p-cin-euwe4-prod-sonicconsumer-svc-101 with HTTP; Tue, 31 Mar 2026 14:04:06 +0000 Received: from dip95.lsn.ir2.yahoo.com ([87.248.99.104]) by hello (SMTP) with SMTP ID 002a7488183940132c044506f3475342 for ; Tue, 31 Mar 2026 14:04:04 +0000 (UTC) Content-Type: text/plain; charset=utf-8 Message-ID: <1774965818283.1983519908.748210733@yahoo.de> Cc: internals@lists.php.net Subject: Re: [PHP-DEV] RFC proposal: Invokable interface Date: Tue, 31 Mar 2026 14:04:03 +0000 X-Mailer: Vivaldi Mail User-Agent: Vivaldi Mail/7.9.3970.45 Content-Transfer-Encoding: quoted-printable Precedence: list list-help: list-unsubscribe: list-post: List-Id: x-ms-reactions: disallow MIME-Version: 1.0 References: <1774965818283.1983519908.748210733.ref@yahoo.de> From: hanskrentel@yahoo.de (Hans Krentel) On Monday 30 March 2026 20:37:28 (+02:00), Larry Garfield wrote: > On Mon, Mar 30, 2026, at 6:21 AM, Rowan Tommins [IMSoP] wrote: > > On 30 March 2026 10:51:22 BST, Hans Krentel = wrote: > >> > >>When you spotted those, were they also with such a generic invocable = interface as in this idea in their interface hierarchy? > > > > If they had any interfaces at all, I would expect them to be = specific=20 > > to the use case. As I said earlier, I can't see how you would use = an=20 > > interface that asserted just the existence of the method without any = of=20 > > its signature. > > > > Regards, > > > > Rowan Tommins > > [IMSoP] >=20 > This has sort of come up in designing the compose operator that I've been= working on, on-and-off. I'd want to allow Closure + Closure to return a = closure, but also allow Invokable + Closure, Closure + Invokable, and = Invokable + Invokable to return a closure. But right now there is no = obvious way (to me at least) to detect an Invokable object and treat it = accordingly. So that's where it might be useful to me, at least. >=20 > However, that's an engine level check, not one that would make sense in = user-space. In user space, I'm not entirely sure where you would want this= and not *also* want a use-case-specific interface. >=20 > I've done quite a bit of dynamic dispatch work lately, and is_callable() = and method_exists('__invoke') have sufficed for what I need. >=20 > As an older example: >=20 > https://github.com/php-fig/event-dispatcher-util/blob/master/src/Paramete= rDeriverTrait.php >=20 > I'm sure someone will argue it could be simplified with more modern = assumptions, but for the sake of this thread, how would an Invokable = interface make that code cleaner? Since you wrote that "is_callable() and method_exists('__invoke') = [abbreviated in the original] have sufficed", I imagine that is_invocable()= is clearer than method_exists(), and since there would be an interface for= it: $x instanceof Interface. But that=E2=80=99s perhaps just my opinion, because for structural and = implementation inheritance, I=E2=80=99ve also found that method_exists(...)= is practical, and as is so often the case in PHP script code, = there=E2=80=99s a certain tendency that steers the code in that direction, = and that can be fine; nevertheless, I would say that I personally would = still prefer interface inheritance, so the minimal addition I could imagine= ad hoc would be an extension of that, similar to what you wrote, to also = have an application-specific interface. If I=E2=80=99m not mistaken, this = cannot yet be declared as an extension with non-optional method parameters,= but that doesn=E2=80=99t answer the previously raised questions about = whether this is necessary for PHP scripting scenarios. However, this is = merely a preference for interface inheritance; the advantage of structural = and implementation-based inheritance remains, since the interface is = automatically assigned. Therefore, I would conclude that some = detail-oriented developers might gain even more clarity from this. It is = really difficult to argue about things we cannot yet see, and contracts = only provide as much as the concrete contract can guarantee. Given the event is the interface, it certainly is invocable. -- hakre