Re: [RFC][DISCUSSION] Collection Inspection
| From: | Christoph M. Becker | Date: | Tue, 30 Jan 2018 12:00:47 +0000 |
| Subject: | Re: [RFC][DISCUSSION] Collection Inspection | ||
| References: | 1 2 3 4 5 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-101731@lists.php.net to get a copy of this message | ||
On 30.01.2018 at 01:46, Michael Morris wrote:
> So what about this function
>
> bool array_test(array $array [, callable $callback [, mixed $flag = 0]])
>
> Iterates over $array, passing the value of each element to $callback. If
> the callback returns true for all elements the array_test returns true,
> otherwise it returns false. It is not guaranteed to iterate over the entire
> array - it stops when the first false result is returned by the callback.
> Flags are the same as array_filter.
>
> So...
> assert( array_test($a, 'is_string'), TypeError);
> assert( array_test($a, function($v) { return $v instanceof SomeClass; }),
> TypeError);
>
>
> Not what I came into the thread looking for, but it's not bad.
See <https://github.com/php/php-src/pull/1385>
which apparently has been
abandoned, unfortunately.
--
Christoph M. Becker