Hi Marco Pivetta,

> Would it make sense, instead of having a third boolean parameter (causing two 
> parameters to be coupled together - already quite messy with existing array 
> functions) for `any()` and `all()` to just detect if the given callback 
> requires >1 parameter?
> 
> That would make this much simpler.

I find that to be inconsistent with how other internal functions accepting 
callbacks such as `array_filter` behave.
It would also be unexpected if users or tooling wrap callbacks with other 
callbacks.
Developers would also expect `func_get_args()` to work.

```
<?php
function my_none(iterable $values, callable $predicate) {
    return all($values, fn(...$args) => $predicate(...$args));
}
// PHP can't distinguish between these when given `fn(...$args)`
// - would throw if passed 1 parameter
my_none($values, fn($value, $key) => $value == true || $key == 'x');
// - would throw if passed 2 parameters (too many)
my_none($values, 'is_string');
```

Thanks,
- Tyson
--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: https://www.php.net/unsub.php

Reply via email to