Bug #70113 [Opn->Nab]: IteratorIterator doesn't delegate count through count() array function

From: Date: Wed, 22 Jul 2015 17:07:17 +0000
Subject: Bug #70113 [Opn->Nab]: IteratorIterator doesn't delegate count through count() array function
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-194634@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=70113&edit=1 ID: 70113 Updated by: cmb@php.net Reported by: zoeslam at gmail dot com Summary: IteratorIterator doesn't delegate count through count() array function -Status: Open +Status: Not a bug Type: Bug Package: SPL related Operating System: Linux PHP Version: 5.6.11 -Assigned To: +Assigned To: cmb Block user comment: N Private report: N New Comment: Sorry, but your problem does not imply a bug in PHP itself. For a list of more appropriate places to ask for help using PHP, please visit http://www.php.net/support.php as this bug system is not the appropriate forum for asking support questions. Due to the volume of reports we can not explain in detail here why your report is not a bug. The support channels will be able to provide an explanation for you. Thank you for your interest in PHP. FilterIterator doesn't implement Countable. You can do it yourself, though, see <http://3v4l.org/gfZrT>. Previous Comments: ------------------------------------------------------------------------ [2015-07-22 12:48:50] zoeslam at gmail dot com The bug is in the main IteratorIterator class I suppose: http://3v4l.org/e14aG ------------------------------------------------------------------------ [2015-07-22 12:45:39] zoeslam at gmail dot com Description: ------------ FilterIterator doesn't delegate count through count() array function. It's ok if called as a method. It affects all PHP versions: http://3v4l.org/jKOgZ Test script: --------------- <?php class MyFilter extends FilterIterator { public function accept() { return true; } } $it = new ArrayIterator(array(1, 2, 3)); $fi = new MyFilter($it); var_dump($it->count()); var_dump($fi->count()); var_dump(count($it)); var_dump(count($fi)); Expected result: ---------------- int(3) int(3) int(3) int(3) Actual result: -------------- int(3) int(3) int(3) int(1) ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=70113&edit=1

« previous php.bugs (#194634) next »