Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:128208 X-Original-To: internals@lists.php.net Delivered-To: internals@lists.php.net Received: from php-smtp4.php.net (php-smtp4.php.net [45.112.84.5]) by lists.php.net (Postfix) with ESMTPS id ED7A51A00BC for ; Thu, 24 Jul 2025 11:52:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1753357834; bh=BLXKDXlGZ13ewkl1JH8mMGnSN0NJxfqbgVe9hWS3+/g=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=WkYFuellpjFIQjovTyc3E4mXIWE4ixDg1I0yq58VvFFxjEGfGmhRvURQYZYpAaoiV 3A/Ek2QpK713W7+1QtLI+Wp361nC/oA0hzqUgns3w6bQlzRavGgq9Y61rNhR15p40u 9tIj/D+4cj6lkVZWrMEygXlgmOrkJpdrh6zjXxb+ii0R+sXmqEqtLpHM+GipwuzgFv AKeE+ujlw6PwzMt0TfYw0iwUM/wu28ldAUlCe3GxX3JosMMKkNB8pJ1R86IchCrWIY ZYVOlK86sx30ZQFoFDvqjOz4xawyYnP/BBGjQuAlKZ1zE4FqEwxqna4EpSuN3VjAGh ryoJ0J/klHfOw== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id CC84A180084 for ; Thu, 24 Jul 2025 11:50:32 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on php-smtp4.php.net X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,DMARC_PASS,SPF_HELO_NONE, SPF_PASS autolearn=no autolearn_force=no version=4.0.1 X-Spam-Virus: Error (Cannot connect to unix socket '/var/run/clamav/clamd.ctl': connect: Connection refused) X-Envelope-From: Received: from chrono.xqk7.com (chrono.xqk7.com [176.9.45.72]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Thu, 24 Jul 2025 11:50:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bastelstu.be; s=mail20171119; t=1753357934; bh=MHaZKHjWw8+jTb8vDpy88AXBM6m4F/a8uiGAO7Fs5Ac=; h=MIME-Version:Date:From:To:Cc:Subject:In-Reply-To:References: Message-ID:Content-Type:from:to:cc:subject:message-id; b=NniRwTR9zQGUQqPJPYw6h0sgPo5hfP2QvTbJqMERF2c2feLUUpvwQyDyDdfCIAYUT 5rkpNYiOiG6ZVGjEpOH7oqtF4m5bHZLHJozjuHCihjRiPAUQ5bVA+A8Pcsiseyj1es JB+DNBIbn1vyUps6wTbhkrT55Gzh3CK1h1bsbFgzfbX0ZEZsGAJprtPSUDzBHGiXbB qJl+9QfoKnnJk8UfbUnyK5AYZtIZ1hZBRIuN4C0GxjI46no46bQU7Li9gFwjOJfG0d nqe5fWcuAA/grOaOizJzq6N2cAY44i1SwkdmBcPri2dyI+/+1K0TkwbQaYzO60J+sk JwbkweMK4VpdA== Precedence: bulk list-help: list-post: List-Id: internals.lists.php.net x-ms-reactions: disallow MIME-Version: 1.0 Date: Thu, 24 Jul 2025 13:52:14 +0200 To: Larry Garfield Cc: php internals Subject: Re: [PHP-DEV] [RFC] Partial Function Application v2 In-Reply-To: <395ee57ca13b16ab09301f9bee6f07b9@bastelstu.be> References: <52dbe5236df460958644677c781513c3@bastelstu.be> <395ee57ca13b16ab09301f9bee6f07b9@bastelstu.be> Message-ID: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit From: tim@bastelstu.be (=?UTF-8?Q?Tim_D=C3=BCsterhus?=) Hi Am 2025-07-24 12:03, schrieb Tim Düsterhus: > I don't think they should. Specifically the (1) and (3) should not. My > expectation is that: > > $f = foo(a: ?, b: 2, c: ?); > $f(1, 3); // calls foo(1, 2, 3); > > and > > $f = foo(c: ?, b: 2, a: ?); > $f(1, 3); // calls foo(3, 2, 1); > > The order of the question marks should match the order of the > parameters in the resulting Closure, which is not necessarily the order > of the order parameters of the original function. To add to that: By respecting the order of question marks as written, it would also make PFA easier to understand and also more powerful. After sending the email earlier, I came across this doctrine/collections PR, while reviewing some dependency upgrades: https://github.com/doctrine/collections/pull/424 When migrating the `findFirst()` method from a custom foreach loop to `array_find()`, they couldn't pass along the given callable directly, since Doctrine opted for a different parameter order. Thus they needed an intermediate Closure to swap the arguments. If the argument names for the function are known (which they are not in the Doctrine example, as it's an arbitrary Closure that is given), this would allow to swap arguments as necessary: function cb($key, $val) { … } array_find($array, cb(val: ?, key: ?)); // array_find expects $value, $key. Best regards Tim Düsterhus