Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:115263 Return-Path: Delivered-To: mailing list internals@lists.php.net Received: (qmail 85827 invoked from network); 1 Jul 2021 15:10:53 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 1 Jul 2021 15:10:53 -0000 Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id BB4EA180532 for ; Thu, 1 Jul 2021 08:31:25 -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=-2.6 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_LOW,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL, SPF_HELO_PASS,SPF_NONE autolearn=no autolearn_force=no version=3.4.2 X-Spam-Virus: No X-Envelope-From: Received: from out4-smtp.messagingengine.com (out4-smtp.messagingengine.com [66.111.4.28]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (4096 bits)) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Thu, 1 Jul 2021 08:31:25 -0700 (PDT) Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailout.nyi.internal (Postfix) with ESMTP id 6D9C15C0166 for ; Thu, 1 Jul 2021 11:31:25 -0400 (EDT) Received: from imap43 ([10.202.2.93]) by compute1.internal (MEProxy); Thu, 01 Jul 2021 11:31:25 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to:x-me-proxy :x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm3; bh=S8ftWd 84k00mhND1cR7Q7J8Z4mUN0lTLiDyUQpKnXk0=; b=sqDR+E/pwdulsyDdVNHUSv heHAGp7NJvcB5tMfri0o+8fcBmchYcR2HhaEob9dpfni22EUtNyM9oQ9bzw43IOa 540H1alnzPW9qlitLPpb8rIOiCXlfi135tGE/onTjbQK762pBAocOUD5k1kxFoFC dYz5r0DTu6EuQRnL42pvrec4KhINI+XdRsw71GbXpU+1Pc4t6PnFPgzTgcCVlhYj xjr0s60qfLlAUJoyzHyAz8woD1SvHmNwO0PaSpExWzgI6c7uiZHavoXy3HBjguW0 Cony8gHnHLJkFsfG8omo21tYxResqoMSdqwCuXEPApw0XY7Ks41M7Lrj1bW6e/vA == X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduledrfeeiiedgkeekucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhepofgfggfkjghffffhvffutgesthdtredtreerjeenucfhrhhomhepfdfnrghr rhihucfirghrfhhivghlugdfuceolhgrrhhrhiesghgrrhhfihgvlhguthgvtghhrdgtoh hmqeenucggtffrrghtthgvrhhnpefgueeftdejleduffetvddvffejfeehgeekffduueeh tdfhgfeftdffheetteejveenucffohhmrghinhepghhithhhuhgsrdgtohhmnecuvehluh hsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomheplhgrrhhrhiesghgr rhhfihgvlhguthgvtghhrdgtohhm X-ME-Proxy: Received: by mailuser.nyi.internal (Postfix, from userid 501) id 31BB1AC0076; Thu, 1 Jul 2021 11:31:25 -0400 (EDT) X-Mailer: MessagingEngine.com Webmail Interface User-Agent: Cyrus-JMAP/3.5.0-alpha0-530-gd0c265785f-fm-20210616.002-gd0c26578 Mime-Version: 1.0 Message-ID: <4776c6ba-7d0d-4383-bc2e-a172d9bf11e1@www.fastmail.com> In-Reply-To: References: <1ae611cb-b077-3db0-3237-c7ffa1c6e745@ralphschindler.com> Date: Thu, 01 Jul 2021 10:31:04 -0500 To: "php internals" Content-Type: text/plain Subject: =?UTF-8?Q?Re:_[PHP-DEV]_[Proposal]_call=5Fuser=5Ffunc=5Fmap():_flexible_?= =?UTF-8?Q?named_parameter_mapping_for_call=5Fuser=5Ffunc*?= From: larry@garfieldtech.com ("Larry Garfield") On Thu, Jul 1, 2021, at 10:14 AM, Ralph Schindler wrote: > (Jump to bottom for alternative suggestion that achieves same goals) > > > > > Just to make sure I got this right: call_user_func_map() is the same as > > call_user_func_array(), but a) only accepts named params > > Yes, only accepts named parameters (associative array), > > > and b) silently ignores unknown named params? > I would characterize this as "explicitly doesn't pass unrequested > parameters" > > > I'm not really convinced by your use-case here. This seems like a rather > > odd way to design an API, which goes against commonplace assumptions. If > > I didn't invest a lot of thought in the use case to make the argument, ha. > > That said, I disagree with "odd way to design an API" sentiment... > > This is a common idiom in a few different places found inside > frameworks. Laravel and Symfony both do named argument mapping when > dispatching controller actions. Additionally, both containers do a > significant amount of work with Reflection to map named arguments with > potential parameters. > > I am not discrediting the fact that they don't also do more complex > stuff, but I think this supports the argument that this method of > parameters mapping does not go against commonplace assumptions. > > Eg: > https://github.com/symfony/http-kernel/blob/5.3/HttpKernel.php#L149-L157 > https://github.com/symfony/dependency-injection/search?q=reflectionMethod > https://github.com/laravel/framework/blob/8.x/src/Illuminate/Container/Container.php#L649 What I don't understand is what the issue with that is? You can already build up a named array and splat it into a function call to pass by name. It's a really neat trick. It doesn't need a dedicated function. About a month ago, I went through all of TYPO3 and removed all remaining call_user_func_array() calls in favor of just $function(...$args), because it does the same thing and is faster, and easier to read. Named arguments already work exactly that way, too. I don't see an advantage to adding a function that does what you can already do with less syntax: $args['foo'] = 5; $args['beep'] = get_value_from_db(); $args['narf'] = 'poink'; $callable(...$args); That works today in 8.0. We're good. --Larry Garfield