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

From: Date: Wed, 22 Jul 2015 12:45:39 +0000
Subject: Bug #70113 [NEW]: FilterIterator doesn't delegate count through count() array function
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-194622@lists.php.net to get a copy of this message
From: zoeslam at gmail dot com Operating system: Linux PHP version: 5.6.11 Package: SPL related Bug Type: Bug Bug description:FilterIterator doesn't delegate count through count() array function 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 bug report at https://bugs.php.net/bug.php?id=70113&edit=1 -- Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=70113&r=trysnapshot54 Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=70113&r=trysnapshot55 Try a snapshot (trunk): https://bugs.php.net/fix.php?id=70113&r=trysnapshottrunk Fixed in SVN: https://bugs.php.net/fix.php?id=70113&r=fixed Fixed in release: https://bugs.php.net/fix.php?id=70113&r=alreadyfixed Need backtrace: https://bugs.php.net/fix.php?id=70113&r=needtrace Need Reproduce Script: https://bugs.php.net/fix.php?id=70113&r=needscript Try newer version: https://bugs.php.net/fix.php?id=70113&r=oldversion Not developer issue: https://bugs.php.net/fix.php?id=70113&r=support Expected behavior: https://bugs.php.net/fix.php?id=70113&r=notwrong Not enough info: https://bugs.php.net/fix.php?id=70113&r=notenoughinfo Submitted twice: https://bugs.php.net/fix.php?id=70113&r=submittedtwice register_globals: https://bugs.php.net/fix.php?id=70113&r=globals PHP 4 support discontinued: https://bugs.php.net/fix.php?id=70113&r=php4 Daylight Savings: https://bugs.php.net/fix.php?id=70113&r=dst IIS Stability: https://bugs.php.net/fix.php?id=70113&r=isapi Install GNU Sed: https://bugs.php.net/fix.php?id=70113&r=gnused Floating point limitations: https://bugs.php.net/fix.php?id=70113&r=float No Zend Extensions: https://bugs.php.net/fix.php?id=70113&r=nozend MySQL Configuration Error: https://bugs.php.net/fix.php?id=70113&r=mysqlcfg

« previous php.bugs (#194622) next »