Bug #72499 [NEW]: Generator count always showing 1, seems to not be countable
| From: | kjarli at gmail dot com | Date: | Mon, 27 Jun 2016 06:21:03 +0000 |
| Subject: | Bug #72499 [NEW]: Generator count always showing 1, seems to not be countable | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-201860@lists.php.net to get a copy of this message | ||
From: kjarli at gmail dot com
Operating system: 3v4l.org
PHP version: 5.5.37
Package: *General Issues
Bug Type: Bug
Bug description:Generator count always showing 1, seems to not be countable
Description:
------------
When I use count() on iterators or arrays for example, I always get the
number. For Generators, I will have to call array_to_iterator first. I'm
not too familiar with how this is supposed to work so I was wondering if
this was a bug or not.
If this is not a bug, feel free to close it.
Test script:
---------------
https://3v4l.org/uscsN
Expected result:
----------------
I would expect the Generator to implement the Countable interface and
call iterator_to_array internally or something.
Actual result:
--------------
see link
--
Edit bug report at https://bugs.php.net/bug.php?id=72499&edit=1
--
Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=72499&r=trysnapshot54
Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=72499&r=trysnapshot55
Try a snapshot (trunk): https://bugs.php.net/fix.php?id=72499&r=trysnapshottrunk
Fixed in SVN: https://bugs.php.net/fix.php?id=72499&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=72499&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=72499&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=72499&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=72499&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=72499&r=support
Expected behavior: https://bugs.php.net/fix.php?id=72499&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=72499&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=72499&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=72499&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=72499&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=72499&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=72499&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=72499&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=72499&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=72499&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=72499&r=mysqlcfg