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

From: Date: Wed, 22 Jul 2015 12:48:50 +0000
Subject: Bug #70113 [Opn]: IteratorIterator doesn't delegate count through count() array function
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-194623@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 User updated by: zoeslam at gmail dot com Reported by: zoeslam at gmail dot com -Summary: FilterIterator doesn't delegate count through count() array function +Summary: IteratorIterator doesn't delegate count through count() array function Status: Open Type: Bug Package: SPL related Operating System: Linux PHP Version: 5.6.11 Block user comment: N Private report: N New Comment: The bug is in the main IteratorIterator class I suppose: http://3v4l.org/e14aG Previous Comments: ------------------------------------------------------------------------ [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 (#194623) next »