Re: [Proposal] call_user_func_map(): flexible named parameter mapping for call_user_func*

From: Date: Fri, 02 Jul 2021 05:05:43 +0000
Subject: Re: [Proposal] call_user_func_map(): flexible named parameter mapping for call_user_func*
References: 1 2  Groups: php.internals 
Request: Send a blank email to internals+get-115272@lists.php.net to get a copy of this message


> On Jul 2, 2021, at 12:30 AM, Hossein Baghayi <hossein.baghayi@gmail.com> wrote:
> 
> Hello,
> 
> On Sun, 27 Jun 2021 at 19:09, Ralph Schindler <ralph@ralphschindler.com>
> wrote:
> 
>> 
>> This proposes a method for a publisher/framework/producer (the caller of
>> the callback) to document all the parameters that are available as named
>> parameters, and subscribers/consumers (creator of the callback) could
>> subscribe to what they need by name.
>> 
> 
> Wouldn't it rather be nice if we had more detailed callable types instead?
> I mean instead of simply defining a parameter type as callable we could
> specifically define what the callable expects.
> 
> Something like this:
> ```
> function bar ((int, string):bool $callback) {...}
> ```
> 
> A more generic approach that could be more descriptive, maybe.
> 
> I have no clue if this was already discussed in other threads or not. And
> whether it is feasible to implement.


From 2015 which failed (not sure why): 

https://wiki.php.net/rfc/callable-types

But I believe that would be better to be part of a broader ability to define our own types, e.g.

type function(int, string):bool IntStrFunc;
function bar (intStrFunc $callback) {...}

I think a few have mentioned user-defined types in the recent past but I am not aware of it being a
current RFC for it. 

-Mike


Thread (9 messages)

« previous php.internals (#115272) next »