Countable interface prevents using 2nd parameter ($mode) of count() function
| Bug #67064 | Countable interface prevents using 2nd parameter ($mode) of count() function | ||||
|---|---|---|---|---|---|
| Submitted: | 2014-04-13 17:09 UTC | Modified: | 2014-08-04 08:35 UTC | ||
| From: | trainmaster at gmx dot net | Assigned: | |||
| Status: | Closed | Package: | SPL related | ||
| PHP Version: | Irrelevant | OS: | Windows 7 64 bit | ||
| Private report: | No | CVE-ID: | None | ||
[2014-04-13 17:09 UTC] 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
Patches
bug67064-BC (last revision 2014-06-13 13:53 UTC by mbeccati@php.net)Pull Requests
History
AllCommentsChangesGit/SVN commits
[2014-04-13 17:17 UTC] bwoebi@php.net
-Status: Open +Status: Assigned -Assigned To: +Assigned To: bwoebi
[2014-04-13 17:17 UTC] bwoebi@php.net
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.[2014-04-13 17:24 UTC] bwoebi@php.net
-Status: Assigned +Status: Closed
[2014-06-13 13:57 UTC] mbeccati@php.net
[2014-06-13 16:42 UTC] bwoebi@php.net
[2014-07-30 18:40 UTC] tyrael@php.net
-Status: Closed +Status: Re-Opened
[2014-08-04 08:26 UTC] ab@php.net
-Status: Re-Opened +Status: Closed
[2014-08-04 08:35 UTC] bwoebi@php.net
-Status: Closed +Status: Suspended -Assigned To: bwoebi +Assigned To:
[2014-08-04 08:43 UTC] ab@php.net
-Status: Suspended +Status: Closed
[2015-02-06 17:49 UTC] boen dot robot at gmail dot com