Hi,

On 04.10.16 11:32, Craig Duncan wrote:
> 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

FTR, this also applies to certain non-object types too, see
https://3v4l.org/jqntq :

<?php

var_dump(count("string"));
var_dump(count(true));
var_dump(count(false));
var_dump(count(4321));

int(1)
int(1)
int(1)
int(1)

I was hit by this bug just last week :-(

- Markus

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

Reply via email to