Edit report at https://bugs.php.net/bug.php?id=67064&edit=1
ID: 67064
Updated by: bwoebi@php.net
Reported by: trainmaster at gmx dot net
Summary: Countable interface prevents using 2nd parameter
($mode) of count() function
-Status: Open
+Status: Assigned
Type: Bug
Package: SPL related
Operating System: Windows 7 64 bit
PHP Version: Irrelevant
-Assigned To:
+Assigned To: bwoebi
Block user comment: N
Private report: N
New Comment:
When you implement an interface, you always can add an optional parameter:
public function count($mode = COUNT_NORMAL) { ... }
should work too, when I'll fix this bug.
Previous Comments:
------------------------------------------------------------------------
[2014-04-13 17:09:03] trainmaster at gmx dot net
Description:
------------
Implementing the countable interface does not allow to use the $mode parameter of the count()
function.
I think it can be easily fixed without BC.
Test script:
---------------
class Counter implements Countable
{
public function count()
{
var_dump(func_get_arg(0));
return count($this->data);
}
}
$counter = new Counter;
count($counter, COUNT_RECURSIVE);
Expected result:
----------------
// int(1)
Actual result:
--------------
// Warning: func_get_arg(): Argument 0 not passed to function
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=67064&edit=1