Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:120129 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 6624 invoked from network); 25 Apr 2023 18:20:52 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 25 Apr 2023 18:20:52 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id A4E03180544 for ; Tue, 25 Apr 2023 11:20:51 -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=-1.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,FREEMAIL_REPLY, 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-yw1-f173.google.com (mail-yw1-f173.google.com [209.85.128.173]) (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 11:20:51 -0700 (PDT) Received: by mail-yw1-f173.google.com with SMTP id 00721157ae682-555d2b43a23so70183127b3.2 for ; Tue, 25 Apr 2023 11:20:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1682446850; x=1685038850; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=jx+9ajYoLA9tUbR0ypkpTff0Q079i1Gqn38Xu/Joq7I=; b=D//7fzdKyS56Rdm4PqKEzypPHTgTv5A7pzC1+VYG2gVsFvLf7s+Lh4Hq4vyZsFDh2L LM2qwIKnhguoxj5+sH85cy0VavzS4NroleCViAMs/BbBu/10sxfSMySK8zGAfkSaO80F Che7Xd47WhzbQJFIsdXbr17a4Gpi1kXKFxOf56+xk/NflKOthX3w76y4qvM+DTEi19h+ iuR5GP6RX6D8IdGGquuAHyRuXwnlfWfVdCzy43GhS8GYTLKNnwjGy7SJf2+7r8378qKr ykgEzkRyAfBY7hRMh7fwDFRxIaWQv4kUzq5AN/VEFXX3/w5utFtIqp+w28u5yUyusO4B hSVA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1682446850; x=1685038850; 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=jx+9ajYoLA9tUbR0ypkpTff0Q079i1Gqn38Xu/Joq7I=; b=QZXQ2LrUhAhBGXSt9l8IxopB9ekjcuSpGQOqmcvUwZPmxDQTnY0E5LR82vKsIGwFOY OSfgA9eZS1csk+HqDChaJL6GZi2O8XoI3kT/QgGI4Afq9hDFuGPRdpKVZLz2/QBSqqQl EWX1cy6kMcUBNV9ko/16TQJGxfVL+yJWqHWCXmpdkn0R9Sh2u81ShrKb8aAddch9Oa3T Jlpd5UtSxn26aloB3FgC4oJBsZdgGpBJJcRd1vwOPqVC6GQVplUTMnw5miWeqsO2Ch7b 8h5SE8SNjB+uqR70uzOr9oq7OEm47TMm9bFbiVzJX/XVcfizBlslrUf39hUFJKwv6bg3 QE/Q== X-Gm-Message-State: AAQBX9fqTWmenDveiiZ84YVOPY2loHtKDTqhNchOxJObU2VeD9tiANeW y8Hxpphs8pgZnYbMpuqilqL5eWuo9b9zSS4ErL8Oqzpmf2UzTA== X-Google-Smtp-Source: AKy350aBt1F/xLLmzQ3Yr4thFF1Mc6Cm5hH6KGbsB1QFuBByySAIzLjrSpBBMtq6OLKpR6de21WaIfpaAwB6SAs2DZM= X-Received: by 2002:a0d:cad1:0:b0:544:69f5:fadc with SMTP id m200-20020a0dcad1000000b0054469f5fadcmr11951586ywd.6.1682446849944; Tue, 25 Apr 2023 11:20:49 -0700 (PDT) MIME-Version: 1.0 References: <6b5de716-d769-4f0b-b3e6-5a5a211f035a@app.fastmail.com> In-Reply-To: Date: Tue, 25 Apr 2023 20:20:40 +0200 Message-ID: To: Nicolas Grekas Cc: Larry Garfield , php internals Content-Type: multipart/alternative; boundary="000000000000d830f705fa2d2eb0" Subject: Re: [PHP-DEV] [Discussion] Callable types via Interfaces From: michal.brzuchalski@gmail.com (=?UTF-8?Q?Micha=C5=82_Marcin_Brzuchalski?=) --000000000000d830f705fa2d2eb0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Hi Nicolas, wt., 25 kwi 2023, 19:00 u=C5=BCytkownik Nicolas Grekas < nicolas.grekas+php@gmail.com> napisa=C5=82: > Hi all, > > > https://wiki.php.net/rfc/allow_casting_closures_into_single-method_interf= ace_implementations > > > > > https://wiki.php.net/rfc/allow-closures-to-declare-interfaces-they-implem= ent > > 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 coul= d > 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. > Personally I don't like this way of shaping callable types. Given examples are really confusing me. Call of a castTo() with argument representing an interface with a method is confusing as the method magically appears on a closure without explicit binding to it! What if an interface has more than one method? What if I wanna choose which one? For me personally this goes into wrong direction. Cheers, Micha=C5=82 Marcin Brzuchalski > --000000000000d830f705fa2d2eb0--