Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:120128 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 2830 invoked from network); 25 Apr 2023 17:00:26 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 25 Apr 2023 17:00:26 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id CB955180505 for ; Tue, 25 Apr 2023 10:00:25 -0700 (PDT) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on php-smtp4.php.net X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,HTML_MESSAGE, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.2 X-Spam-ASN: AS15169 209.85.128.0/17 X-Spam-Virus: No X-Envelope-From: Received: from mail-wr1-f52.google.com (mail-wr1-f52.google.com [209.85.221.52]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Tue, 25 Apr 2023 10:00:25 -0700 (PDT) Received: by mail-wr1-f52.google.com with SMTP id ffacd0b85a97d-2f40b891420so5810974f8f.0 for ; Tue, 25 Apr 2023 10:00:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1682442024; x=1685034024; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=K35cKioBwouapMQ/KfjEFBqYQ8yM9W3/pSTKBrGaa1g=; b=Vu9NToLOAkuxys03zgrmOiCbRYEB2NpsY12XaLjAjBN8CormwIb0EA0iKLvu2oETML rKZFxBRGHqjP0QCs32ThYoOUa35d1qEAlNPyCDxMjQoQoqrKEKMHv+y2qHwr18WnIrLX RkwJDXh3kWuwLWjjYtRzK1nDCgJgRI9Nk89F09hTP6VTXMQkSlA+68fxiz4vC5eiED6W v+qBzE5S4bwFUDJgv6bdq9zpje2peSQ6l03MqdKSXLVqMKEf8myi0tNysPyR9xiaxA85 MZour+rcNf6zTqr7PMog60x87YUO8Z+4nibImHdeQ6NOtYXjdWx4ODItny+/VCGcam0/ mQlA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1682442024; x=1685034024; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=K35cKioBwouapMQ/KfjEFBqYQ8yM9W3/pSTKBrGaa1g=; b=bqwKn0YZD16XtrVABdLg1Tem1+4AoFafJebERRSCqgY/71Rzmyz9N3CI1BAyCS0l7g 7IwleVYZhptwNvn7676tjLebwr0QuTV+IbqTgBFW3GvPLWz9rqcfJ07Gx7r/JhXvbxb3 jEGw3czbBW9Ge95a3pIxjulXPR+C7TQv1e+Hl5j1SfnSjQTvDVvN73ldcjvieZ3ySXRB dZ6KtdpBXDCK9/poTP9aVUJp5/mITR+c9I3U7NJj+bKBkta98ikCa0QW/fhlbg3B0SWh hBuQSWG8p3xkTwE8WiU/L8G8L1Ew+L8q875ZAajy1V8wQTB2jFQNBdWo6KR2BvSTL5BO SGBQ== X-Gm-Message-State: AAQBX9dZw2zAAq9NTu3Sk7adDIrYfVbbFOyOtcz5MzvpWOotQb5k3JuJ 9QgNOsWUK7+1feqY9h9Q9wtWjAjsX5jLFTt9KNo= X-Google-Smtp-Source: AKy350YCanvnUj3daCw1SdOjnhLZQJikU12BMrd/sXHpV5qsTNlfUuvWN7hcfwjKbBb6trl+VW0A3Ebg8StT6nwv0QU= X-Received: by 2002:a5d:6a08:0:b0:303:49f9:4a71 with SMTP id m8-20020a5d6a08000000b0030349f94a71mr9822557wru.7.1682442023681; Tue, 25 Apr 2023 10:00:23 -0700 (PDT) MIME-Version: 1.0 References: <6b5de716-d769-4f0b-b3e6-5a5a211f035a@app.fastmail.com> In-Reply-To: <6b5de716-d769-4f0b-b3e6-5a5a211f035a@app.fastmail.com> Date: Tue, 25 Apr 2023 19:00:12 +0200 Message-ID: To: Larry Garfield Cc: php internals Content-Type: multipart/alternative; boundary="0000000000002d41a105fa2c0f08" Subject: Re: [PHP-DEV] [Discussion] Callable types via Interfaces From: nicolas.grekas+php@gmail.com (Nicolas Grekas) --0000000000002d41a105fa2c0f08 Content-Type: text/plain; charset="UTF-8" Hi all, https://wiki.php.net/rfc/allow_casting_closures_into_single-method_interface_implementations > > https://wiki.php.net/rfc/allow-closures-to-declare-interfaces-they-implement > https://wiki.php.net/rfc/structural-typing-for-closures Thanks Larry for the nice introduction to those ideas. Personally, I feel like going with adding Closure::castTo() might provide the most immediate benefit. I expanded the rationale on the corresponding RFC and added more examples. I'd appreciate it if all of you reading could have another look to see if that helps to better understand the proposal. strtr(...)->castTo(TranslatableInterface::class) is one example of RFC #1 function ($message, $parameters) implements TranslatableInterface is RFC #2 Both RFCs nicely combine together to cover many cases of typed callabled. Then RFC#3 is a bit more adventurous (according to our understanding) but still desirable as it's essentially about allowing the engine to tentatively call castTo() from RFC#1 when a closure is passed as argument while an interface is expected. We're now wondering if we should start spending time on prototype implementations for #1 and/or #2, and #3 in this order. Should we consider a preliminary vote on the topic? Nicolas --0000000000002d41a105fa2c0f08--