Re: Proposal: Adding functions any(iterable $input, ?callable $cb = null, int $use_flags=0) and all(...)
| From: | Josh Bruce | Date: | Sun, 30 Aug 2020 12:24:35 +0000 |
| Subject: | Re: Proposal: Adding functions any(iterable $input, ?callable $cb = null, int $use_flags=0) and all(...) | ||
| References: | 1 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-111718@lists.php.net to get a copy of this message | ||
>>
>> - the default is
any($iterable, fn ($value) => ...)
>> - or any($iterable, fn ($key) => expr,
>> ARRAY_FILTER_USE_KEY)
>> - or any($iterable, fn ($value, $key) => expr,
>> ARRAY_FILTER_USE_BOTH)
>
> Doesn't the occasional required use of long constant names like ARRAY_FILTER_USE_KEY and
> ARRAY_FILTER_USE_BOTH somewhat negative the benefit of a more concise syntax?
For what it’s worth, the constants do give at least two benefits:
1. Flexibility for adding functionality without signature change.
2. Readability at the call site even if the output isn’t different in most cases.
example(true, true, false);
example(USE_BLUE, DROP_FIRST...
With names arguments in 8 we do get helped, I think.
mb_case_switch had 3 flags in the beginning, now gas 6 - if I’m remembering and interpreting the
docs correctly.
Cheers,
Josh