On 4 October 2016 at 10:32, Craig Duncan <p...@duncanc.co.uk> wrote:
> Hi everybody
>
> I'd like to propose the introduction of warning when counting objects that
> can't be counted.
>
> The default behaviour is to return 1 for these objects, which can be
> misleading and hide bugs when attempting to count iterable objects (eg
> Generators). Adding a warning would alert developers to the issue
>
> https://wiki.php.net/rfc/counting_non_countables
>
> Thanks,
> Craig

I like this. I would personally like to see this behaviour deprecated
and removed in 8.0

You specifically mention that counting scalars is unaffected, is there
a legitimate use-case for being able to use count() on them?

I'd say using count() on a string or an int also constitutes a hidden
bug, as it also always returns 1 regardless of the value.

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

Reply via email to