Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create is_countable() to check if it's safe to call count() #2206

Closed
wants to merge 2 commits into from

Conversation

duncan3dc
Copy link
Member

Following the recently accepted rfc (and pr #2185) it's now a little awkward to avoid warnings when calling count():

is_array($thing) || $thing implements \Countable

It's also not possible to check if an object has a count_elements handler and can be safely passed to count().

This pr adds a new function to address both of the above issues:

is_countable($thing);

@php-pulls
Copy link

Comment on behalf of krakjoe at php.net:

labelling

@duncan3dc duncan3dc closed this Apr 1, 2017
@duncan3dc duncan3dc deleted the is_countable branch April 1, 2017 15:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants