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

From: Date: Tue, 26 Dec 2017 13:17:23 +0000
Subject: Doc #75733 [Com]: count(null) and count(empty-string) raises a warning
References: 1  Groups: php.doc.bugs 
Request: Send a blank email to doc-bugs+get-15311@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 Comment by: spam2 at rhsoft dot net Reported by: php-bug-reports at protonmail dot com Summary: count(null) and count(empty-string) raises a warning Status: Closed Type: Documentation Problem Package: Arrays related Operating System: Ubuntu, Windows PHP Version: 7.2.0 Assigned To: cmb Block user comment: N Private report: N New Comment: this is clearly a documentation problem http://php.net/manual/de/migration72.incompatible.php An E_WARNING will now be emitted when attempting to count() non-countable types (this includes the sizeof() alias function) Previous Comments: ------------------------------------------------------------------------ [2017-12-26 10:46:16] cmb@php.net This bug has been fixed in the documentation's XML sources. Since the online and downloadable versions of the documentation need some time to get updated, we would like to ask you to be a bit patient. Thank you for the report, and for helping us make our documentation better. ------------------------------------------------------------------------ [2017-12-26 10:45:35] cmb@php.net Automatic comment from SVN on behalf of cmb Revision: http://svn.php.net/viewvc/?view=revision&revision=343711 Log: Fix #75733: count(null) and count(empty-string) raises a warning ------------------------------------------------------------------------ [2017-12-26 10:26:29] nikic@php.net It's a typo, s/not/now :) ------------------------------------------------------------------------ [2017-12-26 10:09:12] requinix@php.net It is supposed to warn. https://wiki.php.net/rfc/counting_non_countables ------------------------------------------------------------------------ [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 (#15311) next »