Bug->Doc #75733 [Opn->Ver]: count(null) and count(empty-string) raises a warning

From: Date: Tue, 26 Dec 2017 10:09:13 +0000
Subject: Bug->Doc #75733 [Opn->Ver]: count(null) and count(empty-string) raises a warning
References: 1  Groups: php.doc.bugs 
Request: Send a blank email to doc-bugs+get-15308@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=75733&edit=1 ID: 75733 Updated by: requinix@php.net Reported by: php-bug-reports at protonmail dot com Summary: count(null) and count(empty-string) raises a warning -Status: Open +Status: Verified -Type: Bug +Type: Documentation Problem -Package: Variables related +Package: Arrays related Operating System: Ubuntu, Windows PHP Version: 7.2.0 Block user comment: N Private report: N New Comment: It is supposed to warn. https://wiki.php.net/rfc/counting_non_countables Previous Comments: ------------------------------------------------------------------------ [2017-12-26 09:12:43] php-bug-reports at protonmail dot com 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 this bug report at https://bugs.php.net/bug.php?id=75733&edit=1

« previous php.doc.bugs (#15308) next »