Bug #76470 [Com]: count(false)===1
| From: | mordyg at gmail dot com | Date: | Wed, 13 Jun 2018 13:59:19 +0000 |
| Subject: | Bug #76470 [Com]: count(false)===1 | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-215688@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=76470&edit=1
ID: 76470
Comment by: mordyg at gmail dot com
Reported by: mordyg at gmail dot com
Summary: count(false)===1
Status: Open
Type: Bug
Package: Variables related
Operating System: N/A
PHP Version: 7.1.18
Block user comment: N
Private report: N
New Comment:
Just to clarify ..
count(null) ===0
So if you say this is not a bug as it a non-countable, then you have a new bug, that count(null)
should be 1, not 0
Previous Comments:
------------------------------------------------------------------------
[2018-06-13 13:53:50] mordyg at gmail dot com
Description:
------------
https://github.com/php/php-src/blob/master/ext/standard/array.c#L829
[] is falsey, so count(false) should equal count([])
Code shows otherwise.
Test script:
---------------
echo []?'Y':'N'; // outputs N
echo false?'Y':'N'; //outputs N
echo count([])?'Y':'N'; //outputs N
echo count(false)?'Y':'N'; //outputs Y
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=76470&edit=1