Re: How to detect classes with a count_elements handler in userland?
| From: | Niklas Keller | Date: | Sun, 13 Nov 2016 20:24:43 +0000 |
| Subject: | Re: How to detect classes with a count_elements handler in userland? | ||
| References: | 1 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-96877@lists.php.net to get a copy of this message | ||
2016-11-13 18:34 GMT+01:00 Christoph M. Becker <cmbecker69@gmx.de>:
> Hi!
>
> In the discussion on PR #2185[1] we've stumbled upon the issue of
> internal classes implementing a count_elements handler (but not the
> Countable interface).
>
> Is it possible to detect this in userland? If not, I would suggest that
> we introduce something like is_countable(), so users can check whether
> count() may be safely called on a given value.
>
> [1] <https://github.com/php/php-src/pull/2185>
>
How about just making those classes implement the interface instead?
Regards, Niklas