Doc #79256 [NEW]: generator->next() not behaving as documented.

From: Date: Tue, 11 Feb 2020 10:39:11 +0000
Subject: Doc #79256 [NEW]: generator->next() not behaving as documented.
Groups: php.doc.bugs 
Request: Send a blank email to doc-bugs+get-17291@lists.php.net to get a copy of this message
From:             selanefa at outlook dot com
Operating system: Ubuntu 18.04.3
PHP version:      7.2.27
Package:          Unknown/Other Function
Bug Type:         Documentation Problem
Bug description:generator->next() not behaving as documented.

Description:
------------
---
From manual page: https://php.net/generator.next
---

The documentation states:
Calling Generator::next() is equivalent to calling Generator::send()
with NULL as argument. 

However, calling Generator::send(null) moves the pointer and returns the
current value, while Generator::next() only moves the pointer and
returns nothing.




Test script:
---------------
function generateCountdown(int $start) {
            while ($start>=0) {
                yield $start--;
            }
        }

$gen = generateCountdown(3);

echo $gen->current().PHP_EOL;
echo $gen->send(null).PHP_EOL;
echo $gen->send(null).PHP_EOL;
$gen->next();
echo $gen->current().PHP_EOL;

Expected result:
----------------
3
2
1
0


-- 
Edit bug report at https://bugs.php.net/bug.php?id=79256&edit=1
-- 
Fix committed:                    https://bugs.php.net/fix.php?id=79256&r=fixed
Fixed in release:                 https://bugs.php.net/fix.php?id=79256&r=alreadyfixed
Need backtrace:                   https://bugs.php.net/fix.php?id=79256&r=needtrace
Need Reproduce Script:            https://bugs.php.net/fix.php?id=79256&r=needscript
Try newer version:                https://bugs.php.net/fix.php?id=79256&r=oldversion
Not developer issue:              https://bugs.php.net/fix.php?id=79256&r=support
Expected behavior:                https://bugs.php.net/fix.php?id=79256&r=notwrong
Not enough info:                  https://bugs.php.net/fix.php?id=79256&r=notenoughinfo
Submitted twice:                  https://bugs.php.net/fix.php?id=79256&r=submittedtwice
register_globals:                 https://bugs.php.net/fix.php?id=79256&r=globals
PHP version support discontinued: https://bugs.php.net/fix.php?id=79256&r=phptooold
Daylight Savings:                 https://bugs.php.net/fix.php?id=79256&r=dst
IIS Stability:                    https://bugs.php.net/fix.php?id=79256&r=isapi
Install GNU Sed:                  https://bugs.php.net/fix.php?id=79256&r=gnused
Floating point limitations:       https://bugs.php.net/fix.php?id=79256&r=float
No Zend Extensions:               https://bugs.php.net/fix.php?id=79256&r=nozend
MySQL Configuration Error:        https://bugs.php.net/fix.php?id=79256&r=mysqlcfg


Thread (7 messages)

« previous php.doc.bugs (#17291) next »