|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[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
Patchesbug67064-BC (last revision 2014-06-13 13:53 UTC by mbeccati@php.net)Pull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sun Nov 02 07:00:01 2025 UTC |
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.