Re: Associated Arrays as function parameters

From: Date: Sat, 14 Mar 2020 19:13:58 +0000
Subject: Re: Associated Arrays as function parameters
References: 1 2 3  Groups: php.internals 
Request: Send a blank email to internals+get-109018@lists.php.net to get a copy of this message
On 14/03/2020 15:57, Mike Schinkel wrote:
What you are looking for are Named Parameters, there have been multiple RFCs about which have all been more or less abandoned from what I see. https://wiki.php.net/rfc/namedparameters (From 2012) https://wiki.php.net/rfc/named_params (From 2013) https://wiki.php.net/rfc/simplified_named_params (From 2016)
Can anyone summarize why these did not move forward?
Without digging back into the archives, my memory is that points of discussion included: - The choice of syntax. - Support for internal functions, which don't declare parameters in the same way. I believe this is now solved, or at least vastly improved, by providing reflection information for internal functions via PHP-syntax stubs (see https://externals.io/message/105851 and https://externals.io/message/105970). - Handling of inheritance: what happens if a class overrides a base method (or implements an interface method) but uses different parameter names? If all parameters are immediately accessible by name (i.e. no extra opt-in is needed in the definition), there will be a large amount of existing code which would immediately break LSP this way. - Mixing named and positional parameters in a single function call. - Handling of variadics, both the function foo(...$args) syntax and the special func_get_args() etc functions - Behaviour when a non-optional parameter is skipped (all three RFCs predate https://wiki.php.net/rfc/too_few_args) Regards, -- Rowan Tommins (né Collins) [IMSoP]

« previous php.internals (#109018) next »