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

Reply via email to