From:             alpha at rrs dot at
Operating system: 
PHP version:      5.1.2
PHP Bug Type:     SPL related
Bug description:  Type of retval of Countable::count() is not checked

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 bug report at http://bugs.php.net/?id=37060&edit=1
-- 
Try a CVS snapshot (PHP 4.4): 
http://bugs.php.net/fix.php?id=37060&r=trysnapshot44
Try a CVS snapshot (PHP 5.1): 
http://bugs.php.net/fix.php?id=37060&r=trysnapshot51
Try a CVS snapshot (PHP 6.0): 
http://bugs.php.net/fix.php?id=37060&r=trysnapshot60
Fixed in CVS:                 http://bugs.php.net/fix.php?id=37060&r=fixedcvs
Fixed in release:             
http://bugs.php.net/fix.php?id=37060&r=alreadyfixed
Need backtrace:               http://bugs.php.net/fix.php?id=37060&r=needtrace
Need Reproduce Script:        http://bugs.php.net/fix.php?id=37060&r=needscript
Try newer version:            http://bugs.php.net/fix.php?id=37060&r=oldversion
Not developer issue:          http://bugs.php.net/fix.php?id=37060&r=support
Expected behavior:            http://bugs.php.net/fix.php?id=37060&r=notwrong
Not enough info:              
http://bugs.php.net/fix.php?id=37060&r=notenoughinfo
Submitted twice:              
http://bugs.php.net/fix.php?id=37060&r=submittedtwice
register_globals:             http://bugs.php.net/fix.php?id=37060&r=globals
PHP 3 support discontinued:   http://bugs.php.net/fix.php?id=37060&r=php3
Daylight Savings:             http://bugs.php.net/fix.php?id=37060&r=dst
IIS Stability:                http://bugs.php.net/fix.php?id=37060&r=isapi
Install GNU Sed:              http://bugs.php.net/fix.php?id=37060&r=gnused
Floating point limitations:   http://bugs.php.net/fix.php?id=37060&r=float
No Zend Extensions:           http://bugs.php.net/fix.php?id=37060&r=nozend
MySQL Configuration Error:    http://bugs.php.net/fix.php?id=37060&r=mysqlcfg

Reply via email to