doc-en icon indicating copy to clipboard operation
doc-en copied to clipboard

Meaningless caution on generator syntax page since the related example was removed

Open a-menshchikov opened this issue 4 years ago • 5 comments

From manual page: https://php.net/language.generators.syntax


The following block seems like an artifact:

Caution The value that will be assigned to $data is the value passed to Generator::send(), or null if Generator::next() is called instead.

a-menshchikov avatar Jun 16 '21 18:06 a-menshchikov

That has been added as part of fixing bug 76104. Do you have a suggestion on how to improve this?

cmb69 avatar Jun 16 '21 18:06 cmb69

At least the caution doesn't make sense in context, because it refers to a $data variable that doesn't exist. This was probably moved around to a place where it no longer makes sense.

nikic avatar Jun 18 '21 10:06 nikic

Same for the second one:

Caution As with the simple value yields shown earlier, yielding a key/value pair in an expression context requires the yield statement to be parenthesised:

This is not "shown earlier" and the parentheses requirement is gone in PHP 7, so this one can just be dropped entirely.

nikic avatar Jun 18 '21 10:06 nikic

I think that usage of yield keyword as expression that returns a value should be described in a separate subsection.

a-menshchikov avatar Jun 18 '21 11:06 a-menshchikov

Oh, https://github.com/php/doc-en/commit/cdaea0421544885f02ff3d36bd203dc01b78299e#diff-9e27d08e700634a0fe443f7249fd2bcbcfc7f5c788e96dcd298843b78010ddbc removed the example to which the note was referring to.

cmb69 avatar Jun 18 '21 12:06 cmb69