|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #37060 Type of retval of Countable::count() is not checked
Submitted: 2006-04-12 17:05 UTC Modified: 2006-04-12 19:33 UTC
From: alpha at rrs dot at Assigned: johannes (profile)
Status: Closed Package: SPL related
PHP Version: 5.1.2 OS:
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Bug Type:
From: alpha at rrs dot at
New email:
PHP Version: OS:


 [2006-04-12 17:05 UTC] alpha at rrs dot at
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:

error_reporting(E_ALL | E_STRICT);

class Test implements Countable {
	function count() {
		return '1';

$test = new Test();


Expected result:

Actual result:


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2006-04-12 19:33 UTC]
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
Thank you for the report, and for helping us make PHP better.

PHP Copyright © 2001-2022 The PHP Group
All rights reserved.
Last updated: Wed Oct 05 16:03:45 2022 UTC