Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:108483 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 45036 invoked from network); 11 Feb 2020 16:34:40 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 11 Feb 2020 16:34:40 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id 8B0E8180211 for ; Tue, 11 Feb 2020 06:48:34 -0800 (PST) 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.6 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS, SUBJ_ALL_CAPS 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-lj1-f176.google.com (mail-lj1-f176.google.com [209.85.208.176]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Tue, 11 Feb 2020 06:48:33 -0800 (PST) Received: by mail-lj1-f176.google.com with SMTP id x7so11918333ljc.1 for ; Tue, 11 Feb 2020 06:48:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=/eie2vyfT0Umd37rhwylA85AoUYrWaZiReuPZzWkUXk=; b=WcDBexmU4ejNovt2D+LP9tPXJcULw2+EtR4Tt8akDlIZ24nI01T/52waheZgLkYlEj YjiN4iog64weS/wDhyYoijAW9bXILafT/xxCh4zlH9u+n2MOJEhi6ddMwmPolE/h5itb kRGOfEWWhJGnUaA7G4UKXtRi3HEFCm88uOVnnpqdD2MKiv4TV2vJcnm6wduutDo6eJpX EyiCBK0A/lixhI/6+rPQuH7qqQ5uO4drSf91ZtbKP1+S8GqDaPzWU+PHANXSEDtxC30q mArZ2F0z8+oZu8Vij+2C89X7rsdWBnxjSeX7i30i4Qww2k2zGyU76og++PZntBQOOAUe uYGQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=/eie2vyfT0Umd37rhwylA85AoUYrWaZiReuPZzWkUXk=; b=JLl9i/4f5IksXjpx9ag5fnAcIxR8tSGcFayOoWFJmzqUkVaJLCsE3/lT4g86LvDDkH BNLdPd6JRvhTVcms77f7LjQnR1awddl5hISWi8q80J2CLJFxynW8wEGIyYW0UNUF+Hs1 KMIny+YIPrKF1fyznkXg7q1sqRujO4hIBoH4h45E5sU9UX8nkR+P0XPxu70Pjc6tIt2A c2apvfAz1/PkFIg+9rC3S1o9E7nbW8BwB6wc8IHizS1fCOvefaP8+riB5vwDsXwe2o62 UuwcPXRS5CMrYKwWW6rlvrIpj0bhAkofZ4MkePBTVpIg+7xEBCCAOeVPUrHBJ6aXseBE lXbQ== X-Gm-Message-State: APjAAAUrs1Pxqo/I932lPZZuVmPDy0RktXsBZF4ak2NjC8oxkph5IfdW dralOaIZ38rpSyzx2QbACdb2uIEQWQoTNESoWX0= X-Google-Smtp-Source: APXvYqyIzw7RFvnu0ZzZJ2yVAUptWeVlpYI5tft5b1VMn99V+qsRpbJdPjQsjsQRnHNIpXSTiHwm0+3DOPOlxfXT71s= X-Received: by 2002:a05:651c:102c:: with SMTP id w12mr4481782ljm.53.1581432511458; Tue, 11 Feb 2020 06:48:31 -0800 (PST) MIME-Version: 1.0 References: In-Reply-To: Date: Tue, 11 Feb 2020 15:48:18 +0100 Message-ID: To: Nikita Popov Cc: Nicolas Grekas , Diogo Galvao , PHP Internals List Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Subject: Re: [PHP-DEV] [RFC] From: manuelcanga@gmail.com (Manuel Canga) On Tue, 11 Feb 2020 at 14:19, Nikita Popov wrote: > > On Tue, Feb 11, 2020 at 1:43 PM Manuel Canga wrot= e: >> >> On Tue, 11 Feb 2020 at 13:16, Nicolas Grekas >> wrote: >> > >> > >> > >> > Le mar. 11 f=C3=A9vr. 2020 =C3=A0 12:52, Diogo Galvao a =C3=A9crit : >> >> >> >> On Tue, Feb 11, 2020 at 8:14 AM Manuel Canga = wrote: >> >> > >> >> > Hi internals, >> >> > I Would like to present a possible new "::func resolution" for your >> >> > consideration. >> >> ... >> >> > use function \My\I18N\i18n_translate; >> >> > >> >> > $mapped_array =3D array_map(i18n_translate::func, $array); >> >> ... >> >> > What is your opinion ? Do you see it useful ? >> >> >> >> I've wished for this on many occasions and think it'd be really usefu= l, as long >> >> as it could work with methods as well: >> >> >> >> $mapped_array =3D array_map(I18N::translate::function, $array); >> >> >> >> For what it's worth I guess it could just return [I18N::class, 'trans= late']. >> > >> > >> > I wish this would return a Closure instead, making $foo::function the = equivalent of Closure::fromCallable($foo). >> >> Hi, Nicolas, >> >> Currently, when ::class is used, class with >> can or cannot exists in that moment. >> Using ::func( or ::function ), I think >> should keep the same behavior. >> >> Using ::func as alias of "Closure::fromCallable" check if function >> exists in that moment. It is certainly useful, but, I think it's more >> important be consistent > > > Checking whether the function exists is really unavoidable for functions,= because you don't know whether > > namespace Foo; > var_dump(strlen::function); > > refers to 'Foo\strlen' or 'strlen', without first trying to look up the f= ormer. > > I agree with Nicolas that this kind of feature would provide the most val= ue if it created a Closure. This would circumvent all the issues outlined i= n https://wiki.php.net/rfc/consistent_callables. > > Regards, > Nikita Thanks, Nikita. I don't know that RFC. In that case, why don't use ::callable ?. This will be useful for functions and others callable. E.g: enqueue_task([I18n::class, 'translate']::callable); enqueue_task(translate::callable); Would it be hard to implement in PHP ?