Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:116287 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 72877 invoked from network); 21 Oct 2021 20:18:57 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 21 Oct 2021 20:18:57 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 657181804B0 for ; Thu, 21 Oct 2021 14:07:29 -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.9 required=5.0 tests=BAYES_00,HTML_MESSAGE, SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.2 X-Spam-ASN: AS21554 199.38.80.0/21 X-Spam-Virus: No X-Envelope-From: Received: from mercury.negativeion.net (mercury.negativeion.net [199.38.81.6]) by php-smtp4.php.net (Postfix) with ESMTP for ; Thu, 21 Oct 2021 14:07:28 -0700 (PDT) Received: from localhost (localhost [127.0.0.1]) by mercury.negativeion.net (Postfix) with ESMTP id 74A4820F41C383; Thu, 21 Oct 2021 17:07:28 -0400 (EDT) Received: from mercury.negativeion.net ([127.0.0.1]) by localhost (mercury.negativeion.net [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id seMIcp8c9WPu; Thu, 21 Oct 2021 17:07:27 -0400 (EDT) Received: from smtpclient.apple (unknown [173.225.146.47]) by mercury.negativeion.net (Postfix) with ESMTPSA id 9036B20F41C375; Thu, 21 Oct 2021 17:07:27 -0400 (EDT) Message-ID: <4EAE2521-3DF8-44E4-B7F2-302208083ACF@trowski.com> Content-Type: multipart/alternative; boundary="Apple-Mail=_1EA32F52-CB1A-4C6E-8619-5BB2E468F15F" Mime-Version: 1.0 (Mac OS X Mail 14.0 \(3654.120.0.1.13\)) Date: Thu, 21 Oct 2021 16:07:26 -0500 In-Reply-To: <17c9ff9e9da.10b3e7f1c1280030.5141627710284677362@pmmp.io> Cc: internals To: "Dylan K. Taylor" References: <17c9ff9e9da.10b3e7f1c1280030.5141627710284677362@pmmp.io> X-Mailer: Apple Mail (2.3654.120.0.1.13) Subject: Re: [PHP-DEV] Add ReflectionFunctionAbstract::isAnonymous() From: aaron@trowski.com (Aaron Piotrowski) --Apple-Mail=_1EA32F52-CB1A-4C6E-8619-5BB2E468F15F Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=utf-8 > On Oct 20, 2021, at 6:12 PM, Dylan K. Taylor wrote: >=20 > Hi all,=20 >=20 > Given the addition of Closure::fromCallable() and the upcoming = first-class callable syntax in 8.1, it seems slightly problematic that = there's no simple way to tell by reflection if a Closure refers to an = anonymous function or not. ReflectionFunctionAbstract::isClosure() = (perhaps somewhat misleadingly) returns whether the closure is literally = a \Closure instance, so it's not useful for this purpose.=20 >=20 > The only way to do this currently (that I know about) is to check if = the name of the function contains "{closure}", which is a bit unpleasant = and depends on undocumented behaviour.=20 >=20 > I'm proposing the addition of = ReflectionFunctionAbstract::isAnonymous(), which would fill this use = case, and may be able to offer an implementation.=20 >=20 > Thanks,=20 > Dylan Taylor.=20 >=20 >=20 > --=20 > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: https://www.php.net/unsub.php >=20 Hi Dylan, I recently wrote some code checking for =E2=80=9C{closure}=E2=80=9D: = https://github.com/amphp/amp/blob/27219ddbc0bbc3fd0db4d7380eaed6489c7291ed= /lib/functions.php#L135 = I agree, it is a bit unpleasant and looks like a hack. I would welcome = an isAnonymous() method. Cheers, Aaron Piotrowski= --Apple-Mail=_1EA32F52-CB1A-4C6E-8619-5BB2E468F15F--