Skip to content

Commit e674990

Browse files
Fix grammar in control structures (#5750)
1 parent 7132d88 commit e674990

8 files changed

Lines changed: 50 additions & 49 deletions

File tree

language/control-structures/do-while.xml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,13 @@
77
<simpara>
88
<literal>do-while</literal> loops are very similar to
99
<literal>while</literal> loops, except the truth expression is
10-
checked at the end of each iteration instead of in the beginning.
10+
checked at the end of each iteration instead of at the beginning.
1111
The main difference from regular <literal>while</literal> loops is
1212
that the first iteration of a <literal>do-while</literal> loop is
1313
guaranteed to run (the truth expression is only checked at the end
1414
of the iteration), whereas it may not necessarily run with a
1515
regular <literal>while</literal> loop (the truth expression is
16-
checked at the beginning of each iteration, if it evaluates to
16+
checked at the beginning of each iteration; if it evaluates to
1717
&false; right from the beginning, the loop
1818
execution would end immediately).
1919
</simpara>
@@ -40,7 +40,7 @@ do {
4040
</para>
4141
<simpara>
4242
The above loop would run one time exactly, since after the first
43-
iteration, when truth expression is checked, it evaluates to
43+
iteration, when the truth expression is checked, it evaluates to
4444
&false; (<varname>$i</varname> is not bigger than 0) and the loop
4545
execution ends.
4646
</simpara>

language/control-structures/elseif.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ a is equal to b
4646
<literal>elseif</literal> expression (if any) that evaluates to
4747
&true; would be executed. In PHP, it's possible to write
4848
<literal>else if</literal> (in two words) and the behavior would be identical
49-
to the one of <literal>elseif</literal> (in a single word). The syntactic meaning
49+
to that of <literal>elseif</literal> (in a single word). The syntactic meaning
5050
is slightly different (the same behavior as C) but the bottom line
5151
is that both would result in exactly the same behavior.
5252
</simpara>

language/control-structures/for.xml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ for (expr1; expr2; expr3)
2323
loop.
2424
</simpara>
2525
<simpara>
26-
In the beginning of each iteration,
26+
At the beginning of each iteration,
2727
<varname>expr2</varname> is evaluated. If it evaluates to
2828
&true;, the loop continues and the nested
2929
statement(s) are executed. If it evaluates to
@@ -124,7 +124,7 @@ for ($i = 1, $j = 0; $i <= 10; $j += $i, print $i . " ", $i++);
124124
<simpara>
125125
Of course, the first example appears to be the nicest one (or
126126
perhaps the fourth), but you may find that being able to use empty
127-
expressions in <literal>for</literal> loops comes in handy in many
127+
expressions in <literal>for</literal> loops comes in handy on many
128128
occasions.
129129
</simpara>
130130
<para>
@@ -142,7 +142,7 @@ endfor;
142142
</informalexample>
143143
</para>
144144
<simpara>
145-
It's a common thing to many users to iterate through arrays like in the
145+
It's common for many users to iterate through arrays like in the
146146
example below.
147147
</simpara>
148148
<para>

language/control-structures/foreach.xml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ Dynamic arrays:
143143
<simpara>
144144
Please note that
145145
<link linkend="language.types.array.syntax.destructuring">array destructuring</link>
146-
via <literal>[]</literal> is only possible as of PHP 7.1.0
146+
via <literal>[]</literal> is only possible as of PHP 7.1.0.
147147
</simpara>
148148
</note>
149149
</para>
@@ -291,9 +291,9 @@ array(4) {
291291
</para>
292292
<warning>
293293
<simpara>
294-
Reference to a <literal>$value</literal> of the last array element
295-
remain even after the <literal>foreach</literal> loop. It is recommended
296-
to destroy these using <function>unset</function>.
294+
A reference to the <literal>$value</literal> of the last array element
295+
remains even after the <literal>foreach</literal> loop. It is recommended
296+
to destroy it using <function>unset</function>.
297297
Otherwise, the following behavior will occur:
298298
</simpara>
299299
<informalexample>

language/control-structures/include-once.xml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,14 @@
44
<sect1 xml:id="function.include-once" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
55
<title>include_once</title>
66
<?phpdoc print-version-for="include_once"?>
7-
<para>
7+
<simpara>
88
The <literal>include_once</literal> expression includes and evaluates
99
the specified file during the execution of the script.
10-
This is a behavior similar to the <function>include</function> expression,
10+
This behavior is similar to the <function>include</function> expression,
1111
with the only difference being that if the code from a file has already
1212
been included, it will not be included again, and include_once returns &true;. As the name suggests,
1313
the file will be included just once.
14-
</para>
14+
</simpara>
1515
<para>
1616
<literal>include_once</literal> may be used in cases where
1717
the same file might be included and evaluated more than once during a

language/control-structures/include.xml

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ echo "A $color $fruit"; // A green apple
8383
then all of the code contained in the called file will behave as
8484
though it had been defined inside that function. So, it will follow
8585
the variable scope of that function.
86-
An exception to this rule are <link
86+
An exception to this rule is <link
8787
linkend="language.constants.magic">magic constants</link> which are
8888
evaluated by the parser before the include occurs.
8989
</simpara>
@@ -161,15 +161,15 @@ include 'http://www.example.com/file.php?foo=1&bar=2';
161161
</para>
162162
<warning>
163163
<title>Security warning</title>
164-
<para>
165-
Remote file may be processed at the remote server (depending on the file
166-
extension and the fact if the remote server runs PHP or not) but it still
164+
<simpara>
165+
A remote file may be processed at the remote server (depending on the file
166+
extension and whether or not the remote server runs PHP) but it still
167167
has to produce a valid PHP script because it will be processed at the
168168
local server. If the file from the remote server should be processed
169-
there and outputted only, <function>readfile</function> is much better
169+
there and outputted only, <function>readfile</function> is a much better
170170
function to use. Otherwise, special care should be taken to secure the
171171
remote script to produce a valid and desired code.
172-
</para>
172+
</simpara>
173173
</warning>
174174
<para>
175175
See also <link linkend="features.remote-files">Remote files</link>,
@@ -194,7 +194,7 @@ include 'http://www.example.com/file.php?foo=1&bar=2';
194194
<para>
195195
Because <literal>include</literal> is a special language construct,
196196
parentheses are not needed around its argument. Take care when comparing
197-
return value.
197+
the return value.
198198
<example>
199199
<title>Comparing return value of include</title>
200200
<programlisting role="php" annotations="non-interactive">
@@ -257,15 +257,15 @@ echo $bar; // prints 1
257257
If the file can't be included, &false; is returned and
258258
<constant>E_WARNING</constant> is issued.
259259
</simpara>
260-
<para>
260+
<simpara>
261261
If there are functions defined in the included file, they can be used in the
262-
main file independent if they are before <function>return</function> or after.
262+
main file regardless of whether they are before <function>return</function> or after.
263263
If the file is included twice, PHP will raise a fatal error because the
264264
functions were already declared.
265265
It is recommended to use <function>include_once</function> instead of
266-
checking if the file was already included and conditionally return inside
266+
checking if the file was already included and conditionally returning inside
267267
the included file.
268-
</para>
268+
</simpara>
269269
<simpara>
270270
Another way to "include" a PHP file into a variable is to capture the
271271
output by using the <link linkend="ref.outcontrol">Output Control

language/control-structures/match.xml

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ string(8) "Teenager"
8686
<note>
8787
<simpara>
8888
When a <literal>match</literal> expression is used as a standalone
89-
expression it <emphasis>must</emphasis> be terminated
89+
expression, it <emphasis>must</emphasis> be terminated
9090
by a semicolon <literal>;</literal>.
9191
</simpara>
9292
</note>
@@ -110,7 +110,7 @@ string(8) "Teenager"
110110
</listitem>
111111
<listitem>
112112
<simpara>
113-
<literal>match</literal> arms do not fall-through to later cases the way
113+
<literal>match</literal> arms do not fall through to later cases the way
114114
<literal>switch</literal> statements do.
115115
</simpara>
116116
</listitem>
@@ -123,7 +123,7 @@ string(8) "Teenager"
123123
</para>
124124

125125
<para>
126-
As <literal>switch</literal> statements, <literal>match</literal>
126+
Like <literal>switch</literal> statements, <literal>match</literal>
127127
expressions are executed match arm by match arm.
128128
In the beginning, no code is executed.
129129
The conditional expressions are only evaluated if all previous conditional
@@ -146,11 +146,11 @@ $result = match ($x) {
146146
</informalexample>
147147
</para>
148148

149-
<para>
149+
<simpara>
150150
<literal>match</literal> expression arms may contain multiple expressions
151-
separated by a comma. That is a logical OR, and is a short-hand for multiple
151+
separated by a comma. That is a logical OR, and is a shorthand for multiple
152152
match arms with the same right-hand side.
153-
</para>
153+
</simpara>
154154
<para>
155155
<informalexample>
156156
<programlisting role="php" annotations="non-interactive">
@@ -186,17 +186,17 @@ $expressionResult = match ($condition) {
186186
</informalexample>
187187
<note>
188188
<simpara>
189-
Multiple default patterns will raise a
189+
Multiple default patterns will raise an
190190
<constant>E_FATAL_ERROR</constant> error.
191191
</simpara>
192192
</note>
193193
</para>
194194

195-
<para>
195+
<simpara>
196196
A <literal>match</literal> expression must be exhaustive. If the
197-
subject expression is not handled by any match arm an
197+
subject expression is not handled by any match arm, an
198198
<classname>UnhandledMatchError</classname> is thrown.
199-
</para>
199+
</simpara>
200200

201201
<example>
202202
<title>Example of an unhandled match expression</title>
@@ -240,15 +240,15 @@ object(UnhandledMatchError)#1 (7) {
240240
</example>
241241

242242
<sect2>
243-
<title>Using match expressions to handle non identity checks</title>
243+
<title>Using match expressions to handle non-identity checks</title>
244244
<para>
245245
It is possible to use a <literal>match</literal> expression to handle
246246
non-identity conditional cases by using <code>true</code> as the subject
247247
expression.
248248
</para>
249249

250250
<example>
251-
<title>Using a generalized match expressions to branch on integer ranges</title>
251+
<title>Using a generalized match expression to branch on integer ranges</title>
252252
<programlisting role="php">
253253
<![CDATA[
254254
<?php
@@ -273,7 +273,7 @@ string(11) "young adult"
273273
</example>
274274

275275
<example>
276-
<title>Using a generalized match expressions to branch on string content</title>
276+
<title>Using a generalized match expression to branch on string content</title>
277277
<programlisting role="php">
278278
<![CDATA[
279279
<?php

language/control-structures/switch.xml

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,26 +6,26 @@
66
<?phpdoc print-version-for="switch"?>
77
<simpara>
88
The <literal>switch</literal> statement is similar to a series of
9-
IF statements on the same expression. In many occasions, you may
10-
want to compare the same variable (or expression) with many
9+
<literal>if</literal> statements on the same expression. In situations where
10+
it is necessary to compare the same variable or expression with many
1111
different values, and execute a different piece of code depending
12-
on which value it equals to. This is exactly what the
13-
<literal>switch</literal> statement is for.
12+
on which value it equals, the <literal>switch</literal> statement is often
13+
more convenient and easier to read.
1414
</simpara>
1515
<note>
1616
<simpara>
1717
Note that unlike some other languages, the
1818
<link linkend="control-structures.continue">continue</link> statement
19-
applies to <literal>switch</literal> and acts similar to <literal>break</literal>. If you
19+
applies to <literal>switch</literal> and acts similarly to <literal>break</literal>. If you
2020
have a <literal>switch</literal> inside a loop and wish to continue to the next iteration of
2121
the outer loop, use <literal>continue 2</literal>.
2222
</simpara>
2323
</note>
2424
<note>
25-
<para>
26-
Note that switch/case does
25+
<simpara>
26+
Note that switch/case does a
2727
<link linkend="types.comparisions-loose">loose comparison</link>.
28-
</para>
28+
</simpara>
2929
</note>
3030

3131
<para>
@@ -126,7 +126,7 @@ i equals 2
126126
evaluated only once and the result is compared to each
127127
<literal>case</literal> statement. In an <literal>elseif</literal>
128128
statement, the condition is evaluated again. If your condition is
129-
more complicated than a simple compare and/or is in a tight loop,
129+
more complicated than a simple comparison and/or is in a tight loop,
130130
a <literal>switch</literal> may be faster.
131131
</simpara>
132132
<para>
@@ -190,7 +190,7 @@ i is not equal to 0, 1 or 2
190190
</informalexample>
191191
<note>
192192
<simpara>
193-
Multiple default cases will raise a
193+
Multiple default cases will raise an
194194
<constant>E_COMPILE_ERROR</constant> error.
195195
</simpara>
196196
</note>
@@ -244,7 +244,8 @@ B
244244
</para>
245245
<para>
246246
For more complex comparisons, the value &true; may be used as the switch value.
247-
Or, alternatively, <literal>if</literal>-<literal>else</literal> blocks instead of <literal>switch</literal>.
247+
Or, alternatively, <literal>if</literal>-<literal>else</literal> blocks
248+
can be used instead of <literal>switch</literal>.
248249
<informalexample>
249250
<programlisting role="php">
250251
<![CDATA[

0 commit comments

Comments
 (0)