#37060 [Asn->Csd]: Type of retval of Countable::count() is not checked
| From: | johannes@php.net | Date: | Wed, 12 Apr 2006 19:33:02 +0000 |
| Subject: | #37060 [Asn->Csd]: Type of retval of Countable::count() is not checked | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-95711@lists.php.net to get a copy of this message | ||
ID: 37060
Updated by: johannes@php.net
Reported By: alpha at rrs dot at
-Status: Assigned
+Status: Closed
Bug Type: SPL related
PHP Version: 5.1.2
Assigned To: johannes
New Comment:
This bug has been fixed in CVS.
Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
http://snaps.php.net/.
Thank you for the report, and for helping us make PHP better.
Previous Comments:
------------------------------------------------------------------------
[2006-04-12 17:05:03] alpha at rrs dot at
Description:
------------
If an implementation of Countable::count() does not return an
int the result is a big, "random" number. It seems like the
result is always taken as int even if it's a string or float.
IMHO the result should get typecasted to an int or at least a
warning. If I typecast the result to an int in the return
statement it works as expected.
Reproduce code:
---------------
<?php
error_reporting(E_ALL | E_STRICT);
class Test implements Countable {
function count() {
return '1';
}
}
$test = new Test();
var_dump(count($test));
?>
Expected result:
----------------
int(1)
Actual result:
--------------
int(148313044)
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=37060&edit=1