Re: [RFC] ::func resolution for functions
| From: | Manuel Canga | Date: | Tue, 11 Feb 2020 11:26:45 +0000 |
| Subject: | Re: [RFC] ::func resolution for functions | ||
| References: | 1 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-108461@lists.php.net to get a copy of this message | ||
I'm sorry. I forgot subject due to nerves. I add it.
On Tue, 11 Feb 2020 at 12:13, Manuel Canga <manuelcanga@gmail.com> wrote:
>
> Hi internals,
> I Would like to present a possible new "::func resolution" for your consideration.
>
> In first place, PHP now support "::class" in this way:
>
> use My\I18N;
>
> $mapped_array = array_map([I18N::class, 'translate'], $array);
> It avoid add Full I18N namespace in callback.
>
> However with functions is different:
>
> use function \My\I18N\i18n_translate;
>
> $mapped_array = array_map('\My\I18N\i18n_translate', $array);
>
> What is the useful here of importing the function?.
> My proposal is ":func" in order to avoid full namespace in callback of functions.
> E.g:
>
> use function \My\I18N\i18n_translate;
>
> $mapped_array = array_map(i18n_translate::func, $array);
>
> "<string>::func" should validate if a function with
>
<string> is imported. In this case,
> "<string>::func" is replaced with FQN of this function, otherwise with only
> "<string>"
>
> What is your opinion ? Do you see it useful ?
>
> Thanks and I'm sorry for my English( I'm a Spanish ).
>
> Regards
>
>