Bug #75733 [NEW]: count(null) and count(empty-string) raises a warning

From: Date: Tue, 26 Dec 2017 09:12:46 +0000
Subject: Bug #75733 [NEW]: count(null) and count(empty-string) raises a warning
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-213273@lists.php.net to get a copy of this message
From: php-bug-reports at protonmail dot com Operating system: Ubuntu, Windows PHP version: 7.2.0 Package: Variables related Bug Type: Bug Bug description:count(null) and count(empty-string) raises a warning Description: ------------ Since version of PHP 7.2.0 (stable) and 7.2.1 RC1 count() will raise a warning if argument is either null or empty string. It is hard to file this either as a bug, or documentation problem, because as stated in the manual (here: php.net/manual/en/function.count.php), examples are now obsolete / wrong. Additionally, in the same page in Changelog it is stated this, which adds even more to the confusion: Changelog Version Description 7.2.0 count() will not yield a warning on invalid countable types passed to the array_or_countable parameter. Test script: --------------- $s = ''; echo count($s); // returns 1 with a warning $n = null; echo count($n); // returns 0 with a warning $f = false; echo count($f); // returns 1 with a warning Expected result: ---------------- No warnings issued, or update documentation to include warnings issued. -- Edit bug report at https://bugs.php.net/bug.php?id=75733&edit=1 -- Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=75733&r=trysnapshot54 Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=75733&r=trysnapshot55 Try a snapshot (trunk): https://bugs.php.net/fix.php?id=75733&r=trysnapshottrunk Fixed in SVN: https://bugs.php.net/fix.php?id=75733&r=fixed Fixed in release: https://bugs.php.net/fix.php?id=75733&r=alreadyfixed Need backtrace: https://bugs.php.net/fix.php?id=75733&r=needtrace Need Reproduce Script: https://bugs.php.net/fix.php?id=75733&r=needscript Try newer version: https://bugs.php.net/fix.php?id=75733&r=oldversion Not developer issue: https://bugs.php.net/fix.php?id=75733&r=support Expected behavior: https://bugs.php.net/fix.php?id=75733&r=notwrong Not enough info: https://bugs.php.net/fix.php?id=75733&r=notenoughinfo Submitted twice: https://bugs.php.net/fix.php?id=75733&r=submittedtwice register_globals: https://bugs.php.net/fix.php?id=75733&r=globals PHP 4 support discontinued: https://bugs.php.net/fix.php?id=75733&r=php4 Daylight Savings: https://bugs.php.net/fix.php?id=75733&r=dst IIS Stability: https://bugs.php.net/fix.php?id=75733&r=isapi Install GNU Sed: https://bugs.php.net/fix.php?id=75733&r=gnused Floating point limitations: https://bugs.php.net/fix.php?id=75733&r=float No Zend Extensions: https://bugs.php.net/fix.php?id=75733&r=nozend MySQL Configuration Error: https://bugs.php.net/fix.php?id=75733&r=mysqlcfg

« previous php.bugs (#213273) next »