Skip to content

Commit 1bcc40f

Browse files
committed
Fixed #4800: Check examples in the 'random' section of the manual
1 parent a191392 commit 1bcc40f

File tree

9 files changed

+32
-44
lines changed

9 files changed

+32
-44
lines changed

reference/random/book.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<?xml version="1.0" encoding="utf-8"?>
2-
<book xml:id="book.random" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
2+
<book xml:id="book.random" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink" annotations="interactive">
33
<?phpdoc extension-membership="core" ?>
44
<title>Random Number Generators and Functions Related to Randomness</title>
55
<titleabbrev>Random</titleabbrev>

reference/random/examples.xml

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,38 @@
66
<programlisting role="php">
77
<![CDATA[
88
<?php
9+
$r = new \Random\Randomizer();
910
10-
/* ... */
11+
// Generating a random domain name
12+
printf(
13+
"%s.example.com\n",
14+
$r->getBytesFromString('abcdefghijklmnopqrstuvwxyz0123456789', 16)
15+
);
1116
17+
// Shuffle array:
18+
$fruits = [ 'red' => '🍎', 'green' => '🥝', 'yellow' => '🍌', 'pink' => '🍑', 'purple' => '🍇' ];
19+
echo "Salad: ", implode(', ', $r->shuffleArray($fruits)), "\n";
20+
21+
// Shuffeling array keys
22+
$fruits = [ 'red' => '🍎', 'green' => '🥝', 'yellow' => '🍌', 'pink' => '🍑', 'purple' => '🍇' ];
23+
24+
$keys = $r->pickArrayKeys($fruits, 2);
25+
// Look up the values for the picked keys.
26+
$selection = array_map(
27+
static fn ($key) => $fruits[$key],
28+
$keys
29+
);
30+
31+
echo "Values: ", implode(', ', $selection), "\n";
1232
?>
1333
]]>
1434
</programlisting>
1535
&example.outputs.similar;
1636
<screen>
1737
<![CDATA[
18-
...
38+
j87fzv1p0daiwmlo.example.com
39+
Salad: 🥝, 🍇, 🍎, 🍌, 🍑
40+
Values: 🍌, 🍑
1941
]]>
2042
</screen>
2143
</example>

reference/random/random/engine/mt19937/construct.xml

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,6 @@
1717
</para>
1818

1919
&caution.mt19937-tiny-seed;
20-
21-
&warn.undocumented.func;
22-
2320
</refsect1>
2421

2522
<refsect1 role="parameters">
@@ -77,7 +74,7 @@
7774

7875
<refsect1 role="examples">
7976
&reftitle.examples;
80-
<example>
77+
<example annotations="non-interactive">
8178
<title><function>Random\Engine\Mt19937::__construct</function> example</title>
8279
<programlisting role="php">
8380
<![CDATA[

reference/random/random/engine/pcgoneseq128xslrr64/construct.xml

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,6 @@
1414
<para>
1515

1616
</para>
17-
18-
&warn.undocumented.func;
19-
2017
</refsect1>
2118

2219
<refsect1 role="parameters">
@@ -92,7 +89,7 @@
9289

9390
<refsect1 role="examples">
9491
&reftitle.examples;
95-
<example>
92+
<example annotations="non-interactive">
9693
<title><function>Random\Engine\PcgOneseq128XslRr64::__construct</function> example</title>
9794
<programlisting role="php">
9895
<![CDATA[

reference/random/random/engine/xoshiro256starstar/construct.xml

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,6 @@
1414
<para>
1515

1616
</para>
17-
18-
&warn.undocumented.func;
19-
2017
</refsect1>
2118

2219
<refsect1 role="parameters">
@@ -98,7 +95,7 @@
9895

9996
<refsect1 role="examples">
10097
&reftitle.examples;
101-
<example>
98+
<example annotations="non-interactive">
10299
<title><function>Random\Engine\Xoshiro256StarStar::__construct</function> example</title>
103100
<programlisting role="php">
104101
<![CDATA[

reference/random/random/randomizer/construct.xml

Lines changed: 3 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -37,37 +37,18 @@
3737
</variablelist>
3838
</refsect1>
3939

40-
<!-- Return values commented out, as constructors generally don't return a
41-
value. Uncomment this if you do need a return values section (for
42-
example, because there's also a procedural version of the method).
43-
<refsect1 role="returnvalues">
44-
&reftitle.returnvalues;
45-
<para>
46-
47-
</para>
48-
</refsect1>
49-
-->
50-
51-
5240
<refsect1 role="examples">
5341
&reftitle.examples;
54-
<example>
42+
<example annotations="non-interactive">
5543
<title><function>Random\Randomizer::__construct</function> example</title>
5644
<programlisting role="php">
5745
<![CDATA[
5846
<?php
59-
60-
/* ... */
61-
47+
$r = new \Random\Randomizer();
48+
$r = new \Random\Randomizer(new \Random\Engine\Mt19937());
6249
?>
6350
]]>
6451
</programlisting>
65-
&example.outputs.similar;
66-
<screen>
67-
<![CDATA[
68-
...
69-
]]>
70-
</screen>
7152
</example>
7253
</refsect1>
7354

reference/random/random/randomizer/getint.xml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,6 @@
1515
<para>
1616

1717
</para>
18-
19-
&warn.undocumented.func;
20-
2118
</refsect1>
2219

2320
<refsect1 role="parameters">

reference/random/random/randomizer/nextint.xml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,6 @@
1414
<para>
1515

1616
</para>
17-
18-
&warn.undocumented.func;
19-
2017
</refsect1>
2118

2219
<refsect1 role="parameters">

reference/reflection/book.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<!-- $Revision$ -->
33

4-
<book xml:id="book.reflection" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
4+
<book xml:id="book.reflection" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink" annotations="interactive">
55
<?phpdoc extension-membership="core" ?>
66
<title>Reflection</title>
77
<titleabbrev>Reflection</titleabbrev>

0 commit comments

Comments
 (0)