Re: [PHP-DEV] [RFC] Counting of non-countable objects

2016-10-19 Thread Craig Duncan
On 17 October 2016 at 21:57, Nikita Popov wrote: > > I'm not sure I understand the motivation for throwing a deprecation > notice > > instead of a warning. In particular, what is the action that will be > taken > > here in the next major version? > On 18 October 2016 at 12:53, Christoph M. Becke

Re: [PHP-DEV] [RFC] Counting of non-countable objects

2016-10-18 Thread Christoph M. Becker
On 17.10.2016 at 23:09, Craig Duncan wrote: > On 17 October 2016 at 21:57, Nikita Popov wrote: >> >> I'm not sure I understand the motivation for throwing a deprecation notice >> instead of a warning. In particular, what is the action that will be taken >> here in the next major version? I guess

Re: [PHP-DEV] [RFC] Counting of non-countable objects

2016-10-17 Thread Craig Duncan
On 17 October 2016 at 21:57, Nikita Popov wrote: > > > I'm not sure I understand the motivation for throwing a deprecation notice > instead of a warning. In particular, what is the action that will be taken > here in the next major version? I guess we would throw a warning and return > false (inst

Re: [PHP-DEV] [RFC] Counting of non-countable objects

2016-10-17 Thread Nikita Popov
On Mon, Oct 17, 2016 at 10:50 PM, Craig Duncan wrote: > I've updated the RFC now to include count(null) which resolves the final > open question. > > If there isn't any more feedback I'll open voting in a few days > > https://wiki.php.net/rfc/counting_non_countables > > Thanks, > Craig > I'm not

Re: [PHP-DEV] [RFC] Counting of non-countable objects

2016-10-17 Thread Craig Duncan
I've updated the RFC now to include count(null) which resolves the final open question. If there isn't any more feedback I'll open voting in a few days https://wiki.php.net/rfc/counting_non_countables Thanks, Craig

Re: [PHP-DEV] [RFC] Counting of non-countable objects

2016-10-11 Thread Leigh
On 11 October 2016 at 10:49, Craig Duncan wrote: > I've updated the RFC now to take the deprecation route, and included > counting scalars: > > https://wiki.php.net/rfc/counting_non_countables > > The only remaining issue is what to do about handling *count(null)* > I think this should be deprecat

Re: [PHP-DEV] [RFC] Counting of non-countable objects

2016-10-11 Thread Craig Duncan
I've updated the RFC now to take the deprecation route, and included counting scalars: https://wiki.php.net/rfc/counting_non_countables The only remaining issue is what to do about handling *count(null)* I think this should be deprecated too, but as it's the only case that returns zero I wasn't s

Re: [PHP-DEV] [RFC] Counting of non-countable objects

2016-10-04 Thread Craig Duncan
On 4 October 2016 at 18:10, Nikita Popov wrote: > > A confounding factor is that count() has an alias sizeof() and for people > coming from a C-like background it is quite natural to try to apply > sizeof() to a string in order to get its length. This will silently "work", > but return a meaningl

Re: [PHP-DEV] [RFC] Counting of non-countable objects

2016-10-04 Thread Nikita Popov
On Tue, Oct 4, 2016 at 12:29 PM, Craig Duncan wrote: > On 4 October 2016 at 11:17, Leigh wrote: > > > 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 c

Re: [PHP-DEV] [RFC] Counting of non-countable objects

2016-10-04 Thread Markus Fischer
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 > Generator

Re: [PHP-DEV] [RFC] Counting of non-countable objects

2016-10-04 Thread Craig Duncan
On 4 October 2016 at 11:17, Leigh wrote: > 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

Re: [PHP-DEV] [RFC] Counting of non-countable objects

2016-10-04 Thread Leigh
On 4 October 2016 at 10:32, Craig Duncan 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 ob

[PHP-DEV] [RFC] Counting of non-countable objects

2016-10-04 Thread Craig Duncan
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 developer