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

From: Date: Fri, 13 Mar 2020 18:08:01 +0000
Subject: Doc #79256 [Asn->Csd]: generator->next() not behaving as documented.
References: 1  Groups: php.doc.bugs 
Request: Send a blank email to doc-bugs+get-17414@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=79256&edit=1

 ID:                 79256
 Updated by:         cmb@php.net
 Reported by:        selanefa at outlook dot com
 Summary:            generator->next() not behaving as documented.
-Status:             Assigned
+Status:             Closed
 Type:               Documentation Problem
 Package:            Unknown/Other Function
 Operating System:   Ubuntu 18.04.3
 PHP Version:        7.2.27
 Assigned To:        ekin
 Block user comment: N
 Private report:     N



Previous Comments:
------------------------------------------------------------------------
[2020-03-13 18:07:07] cmb@php.net

Automatic comment from SVN on behalf of cmb
Revision: http://svn.php.net/viewvc/?view=revision&revision=349409
Log: Fix #79256: Generator::next not behaving as documented

Patch provided by ekin@php.net.

------------------------------------------------------------------------
[2020-02-16 14:45:08] ekin@php.net

Looking at this again, I see why that comment is valid.

Calling next() is actually equivalent to send(null), in that they would both advance and also give
you NULL. https://3v4l.org/WokSV

Attempting to use the return value of a void function will evaluate to NULL, with no warnings
emitted. This is what's happening in the next() case.

------------------------------------------------------------------------
[2020-02-14 13:37:25] ekin@php.net

Yeah, I can see that if you're not coming from the Generator::send() page this comment alone
can confuse one.

------------------------------------------------------------------------
[2020-02-14 13:34:39] peehaa@php.net

I agree with OP here. They are not exactly equivalent.

Maybe just remove the description and at a note with something like:

> calling Generator::send() will already advance so there is no need to manually call
> Generator::next()

?

------------------------------------------------------------------------
[2020-02-13 17:41:26] ekin@php.net

Hi, I see your point, though the signature documented should make it obvious that Generator::next()
will not return a value:

public Generator::next ( void ) : void

Is it confusing enough to need clarification, knowing the signature mentions the return type?

------------------------------------------------------------------------


The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at

    https://bugs.php.net/bug.php?id=79256


--
Edit this bug report at https://bugs.php.net/bug.php?id=79256&edit=1


Thread (7 messages)

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