Document more of Generator class

git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@337857 c90b9560-bf6c-de11-be94-00142212c4b1
This commit is contained in:
Thomas Punt 2015-09-20 11:24:26 +00:00
parent 7fa66b6c0b
commit 86ef66a558
4 changed files with 127 additions and 22 deletions

View file

@ -0,0 +1,85 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- $Revision$ -->
<refentry xml:id="generator.getreturn" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
<refnamediv>
<refname>Generator::getReturn</refname>
<refpurpose>Get the return value</refpurpose>
</refnamediv>
<refsect1 role="description">
&reftitle.description;
<methodsynopsis>
<modifier>public</modifier> <type>mixed</type><methodname>Generator::getReturn</methodname>
<void />
</methodsynopsis>
</refsect1>
<refsect1 role="parameters">
&reftitle.parameters;
&no.function.parameters;
</refsect1>
<refsect1 role="returnvalues">
&reftitle.returnvalues;
<para>
Returns the generator's return value once it has finished executing.
</para>
</refsect1>
<refsect1 role="examples">
&reftitle.examples;
<para>
<example>
<title><methodname>Generator::getReturn</methodname> example</title>
<programlisting role="php">
<![CDATA[
<?php
$gen = (function() {
yield 1;
yield 2;
return 3;
})();
foreach ($gen as $val) {
echo $val, PHP_EOL;
}
echo $gen->getReturn(), PHP_EOL;
]]>
</programlisting>
&example.outputs;
<screen>
<![CDATA[
1
2
3
]]>
</screen>
</example>
</para>
</refsect1>
</refentry>
<!-- Keep this comment at the end of the file
Local variables:
mode: sgml
sgml-omittag:t
sgml-shorttag:t
sgml-minimize-attributes:nil
sgml-always-quote-attributes:t
sgml-indent-step:1
sgml-indent-data:t
indent-tabs-mode:nil
sgml-parent-document:nil
sgml-default-dtd-file:"~/.phpdoc/manual.ced"
sgml-exposed-tags:nil
sgml-local-catalogs:nil
sgml-local-ecat-files:nil
End:
vim600: syn=xml fen fdm=syntax fdl=2 si
vim: et tw=78 syn=sgml
vi: ts=1 sw=1
-->

View file

@ -14,11 +14,8 @@
<void />
</methodsynopsis>
<para>
Gets the key of the yielded value.
</para>
&warn.undocumented.func;
</refsect1>
<refsect1 role="parameters">
@ -33,7 +30,34 @@
</para>
</refsect1>
<refsect1 role="examples">
&reftitle.examples;
<para>
<example>
<title><methodname>Generator::key</methodname> example</title>
<programlisting role="php">
<![CDATA[
<?php
function Gen()
{
yield 'key' => 'value';
}
$gen = Gen();
echo "{$gen->key()} => {$gen->current()}";
]]>
</programlisting>
&example.outputs;
<screen>
<![CDATA[
key => value
]]>
</screen>
</example>
</para>
</refsect1>
</refentry>
<!-- Keep this comment at the end of the file

View file

@ -40,6 +40,13 @@
</variablelist>
</refsect1>
<refsect1 role="returnvalues">
&reftitle.returnvalues;
<para>
Returns the yielded value.
</para>
</refsect1>
<refsect1 role="examples">
&reftitle.examples;
<para>
@ -71,14 +78,6 @@ Bye world!
</example>
</para>
</refsect1>
<refsect1 role="returnvalues">
&reftitle.returnvalues;
<para>
Returns the yielded value.
</para>
</refsect1>
</refentry>
<!-- Keep this comment at the end of the file

View file

@ -37,6 +37,13 @@
</varlistentry>
</variablelist>
</refsect1>
<refsect1 role="returnvalues">
&reftitle.returnvalues;
<para>
Returns the yielded value.
</para>
</refsect1>
<refsect1 role="examples">
&reftitle.examples;
@ -73,16 +80,6 @@ Bar
</example>
</para>
</refsect1>
<refsect1 role="returnvalues">
&reftitle.returnvalues;
<para>
Returns the yielded value.
</para>
</refsect1>
</refentry>
<!-- Keep this comment at the end of the file