Re: [RFC] Counting of non-countable objects

From: Date: Tue, 04 Oct 2016 16:57:22 +0000
Subject: Re: [RFC] Counting of non-countable objects
References: 1  Groups: php.internals 
Request: Send a blank email to internals+get-96232@lists.php.net to get a copy of this message
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

« previous php.internals (#96232) next »