Skip to content

Commit 7132d88

Browse files
Fix grammar in language/types (#5746)
1 parent e7ec292 commit 7132d88

18 files changed

Lines changed: 158 additions & 154 deletions

language/types/array.xml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -478,16 +478,16 @@ $arr[] = <replaceable>value</replaceable>;
478478
// <replaceable>key</replaceable> may be an <type>int</type> or <type>string</type>
479479
// <replaceable>value</replaceable> may be any value of any type</synopsis>
480480

481-
<para>
481+
<simpara>
482482
If <varname>$arr</varname> doesn't exist yet or is set to &null; or &false;, it will be created, so this is
483483
also an alternative way to create an <type>array</type>. This practice is
484484
however discouraged because if <varname>$arr</varname> already contains
485485
some value (e.g. <type>string</type> from request variable) then this
486-
value will stay in the place and <literal>[]</literal> may actually stand
486+
value will stay in place and <literal>[]</literal> may actually stand
487487
for <link linkend="language.types.string.substr">string access
488488
operator</link>. It is always better to initialize a variable by a direct
489489
assignment.
490-
</para>
490+
</simpara>
491491
<note>
492492
<simpara>
493493
As of PHP 7.1.0, applying the empty index operator on a string throws a fatal
@@ -1052,17 +1052,17 @@ $error_descriptions[8] = "This is just an informal notice";
10521052
<literal>array($scalarValue)</literal>.
10531053
</para>
10541054

1055-
<para>
1055+
<simpara>
10561056
If an <type>object</type> is converted to an <type>array</type>, the result
10571057
is an <type>array</type> whose elements are the <type>object</type>'s
10581058
properties. The keys are the member variable names, with a few notable
1059-
exceptions: integer properties are unaccessible;
1059+
exceptions: integer properties are inaccessible;
10601060
private variables have the class name prepended to the variable
10611061
name; protected variables have a '*' prepended to the variable name. These
10621062
prepended values have <literal>NUL</literal> bytes on either side.
10631063
Uninitialized <link linkend="language.oop5.properties.typed-properties">typed properties</link>
10641064
are silently discarded.
1065-
</para>
1065+
</simpara>
10661066

10671067
<example>
10681068
<title>Converting to an Array</title>

language/types/callable.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ print implode(' ', $new_numbers);
142142

143143
<simpara>
144144
Static class methods can be used without instantiating an
145-
<type>object</type> of that class by either, creating an array with
145+
<type>object</type> of that class by either creating an array with
146146
the class name at index 0 and the method name at index 1, or by using
147147
the special syntax with the scope resolution operator
148148
<literal>::</literal>, as in <literal>'ClassName::methodName'</literal>.
@@ -196,7 +196,7 @@ print implode(' ', $new_numbers);
196196

197197
<example>
198198
<title>
199-
Calling various types of callables with <function>call_user_function</function>
199+
Calling various types of callables with <function>call_user_func</function>
200200
</title>
201201
<programlisting role="php">
202202
<![CDATA[

language/types/declarations.xml

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,12 @@
1010
otherwise a <classname>TypeError</classname> is thrown.
1111
</para>
1212

13-
<para>
13+
<simpara>
1414
Every single type that PHP supports, with the exception of
15-
<type>resource</type> can be used within a user-land type declaration.
15+
<type>resource</type>, can be used within a user-land type declaration.
1616
This page contains a changelog of availability of the different types
1717
and documentation about usage of them in type declarations.
18-
</para>
18+
</simpara>
1919

2020
<note>
2121
<para>
@@ -137,7 +137,7 @@
137137
<title>Atomic Types Usage Notes</title>
138138

139139
<simpara>
140-
Atomic types have straight forward behaviour with some minor caveats which
140+
Atomic types have straightforward behaviour with some minor caveats which
141141
are described in this section.
142142
</simpara>
143143

@@ -219,7 +219,8 @@ function &test(): void {}
219219
If a pass-by-reference parameter has a type declaration, the type of the
220220
variable is <emphasis>only</emphasis> checked on function entry, at the
221221
beginning of the call, but not when the function returns.
222-
This means that a function can change the type of variable reference.
222+
This means that a function can change the type of the variable
223+
passed by reference.
223224
</simpara>
224225
<example>
225226
<title>Typed pass-by-reference Parameters</title>
@@ -307,7 +308,7 @@ Stack trace:
307308
<simpara>
308309
It is also possible to achieve nullable arguments by making
309310
&null; the default value.
310-
This is not recommended as if the default value is changed in a child
311+
This is not recommended because if the default value is changed in a child
311312
class a type compatibility violation will be raised as the
312313
<type>null</type> type will need to be added to the type declaration.
313314
This behavior is also deprecated since PHP 8.4.

language/types/float.xml

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<!-- $Revision$ -->
33
<sect1 xml:id="language.types.float" xmlns:xlink="http://www.w3.org/1999/xlink">
4-
<title>Floating point numbers</title>
4+
<title>Floating-point numbers</title>
55

6-
<para>
7-
Floating point numbers (also known as "floats", "doubles", or "real numbers")
6+
<simpara>
7+
Floating-point numbers (also known as "floats", "doubles", or "real numbers")
88
can be specified using any of the following syntaxes:
9-
</para>
9+
</simpara>
1010

1111
<informalexample>
1212
<programlisting role="php">
@@ -42,36 +42,36 @@ EXPONENT_DNUM (({LNUM} | {DNUM}) [eE][+-]? {LNUM})
4242
</para>
4343

4444
<warning xml:id="warn.float-precision">
45-
<title>Floating point precision</title>
45+
<title>Floating-point precision</title>
4646

47-
<para>
48-
Floating point numbers have limited precision. Although it depends on the
47+
<simpara>
48+
Floating-point numbers have limited precision. Although it depends on the
4949
system, PHP typically uses the IEEE 754 double precision format, which will
5050
give a maximum relative error due to rounding in the order of 1.11e-16.
51-
Non elementary arithmetic operations may give larger errors, and, of course,
51+
Non-elementary arithmetic operations may give larger errors, and, of course,
5252
error propagation must be considered when several operations are
5353
compounded.
54-
</para>
54+
</simpara>
5555

56-
<para>
57-
Additionally, rational numbers that are exactly representable as floating
58-
point numbers in base 10, like <literal>0.1</literal> or
59-
<literal>0.7</literal>, do not have an exact representation as floating
60-
point numbers in base 2, which is used internally, no matter the size of
56+
<simpara>
57+
Additionally, rational numbers that are exactly representable as floating-point
58+
numbers in base 10, like <literal>0.1</literal> or
59+
<literal>0.7</literal>, do not have an exact representation as floating-point
60+
numbers in base 2, which is used internally, no matter the size of
6161
the mantissa. Hence, they cannot be converted into their internal binary
6262
counterparts without a small loss of precision. This can lead to confusing
6363
results: for example, <literal>floor((0.1+0.7)*10)</literal> will usually
6464
return <literal>7</literal> instead of the expected <literal>8</literal>,
6565
since the internal representation will be something like
6666
<literal>7.9999999999999991118...</literal>.
67-
</para>
67+
</simpara>
6868

69-
<para>
70-
So never trust floating number results to the last digit, and do not compare
71-
floating point numbers directly for equality. If higher precision is
69+
<simpara>
70+
So never trust floating-point number results to the last digit, and do not compare
71+
floating-point numbers directly for equality. If higher precision is
7272
necessary, the <link linkend="ref.bc">arbitrary precision math functions</link>
7373
and <link linkend="ref.gmp">gmp</link> functions are available.
74-
</para>
74+
</simpara>
7575

7676
<para>
7777
For a "simple" explanation, see the <link xlink:href="&url.floating.point.guide;">floating point guide</link>
@@ -117,18 +117,18 @@ EXPONENT_DNUM (({LNUM} | {DNUM}) [eE][+-]? {LNUM})
117117
<sect2 xml:id="language.types.float.comparison">
118118
<title>Comparing floats</title>
119119

120-
<para>
121-
As noted in the warning above, testing floating point values for equality is
120+
<simpara>
121+
As noted in the warning above, testing floating-point values for equality is
122122
problematic, due to the way that they are represented internally. However,
123-
there are ways to make comparisons of floating point values that work around
123+
there are ways to make comparisons of floating-point values that work around
124124
these limitations.
125-
</para>
125+
</simpara>
126126

127-
<para>
128-
To test floating point values for equality, an upper bound on the relative
127+
<simpara>
128+
To test floating-point values for equality, an upper bound on the relative
129129
error due to rounding is used. This value is known as the machine epsilon,
130130
or unit roundoff, and is the smallest acceptable difference in calculations.
131-
</para>
131+
</simpara>
132132

133133
<para>
134134
<varname>$a</varname> and <varname>$b</varname> are equal to 5 digits of

language/types/integer.xml

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
&reftitle.seealso;
1313
<para>
1414
<simplelist>
15-
<member><link linkend="language.types.float">Floating point numbers</link></member>
15+
<member><link linkend="language.types.float">Floating-point numbers</link></member>
1616
<member><link linkend="book.bc">Arbitrary precision / BCMath</link></member>
1717
<member><link linkend="book.gmp">Arbitrary length integer / GMP</link></member>
1818
</simplelist>
@@ -29,12 +29,12 @@
2929
can be used to denote a negative <type>int</type>.
3030
</simpara>
3131

32-
<para>
32+
<simpara>
3333
To use octal notation, precede the number with a <literal>0</literal> (zero).
3434
As of PHP 8.1.0, octal notation can also be preceded with <literal>0o</literal> or <literal>0O</literal>.
35-
To use hexadecimal notation precede the number with <literal>0x</literal>.
36-
To use binary notation precede the number with <literal>0b</literal>.
37-
</para>
35+
To use hexadecimal notation, precede the number with <literal>0x</literal>.
36+
To use binary notation, precede the number with <literal>0b</literal>.
37+
</simpara>
3838

3939
<para>
4040
As of PHP 7.4.0, integer literals may contain underscores (<literal>_</literal>) between digits,
@@ -125,13 +125,13 @@ var_dump(PHP_INT_MAX + 1); // 32-bit system: float(2147483648)
125125
<sect2 xml:id="language.types.integer.division">
126126
<title>Integer division</title>
127127

128-
<para>
129-
There is no <type>int</type> division operator in PHP, to achieve this
128+
<simpara>
129+
There is no <type>int</type> division operator in PHP. To achieve this,
130130
use the <function>intdiv</function> function.
131131
<literal>1/2</literal> yields the <type>float</type> <literal>0.5</literal>.
132132
The value can be cast to an <type>int</type> to round it towards zero, or
133133
the <function>round</function> function provides finer control over rounding.
134-
</para>
134+
</simpara>
135135

136136
<example>
137137
<title>Divisions</title>
@@ -185,7 +185,8 @@ var_dump(round(25/7)); // float(4)
185185
<simpara>
186186
When converting from <type>float</type> to <type>int</type>, the number
187187
will be rounded <emphasis>towards zero</emphasis>.
188-
As of PHP 8.1.0, a deprecation notice is emitted when implicitly converting a non-integral &float; to &integer; which loses precision.
188+
As of PHP 8.1.0, a deprecation notice is emitted when implicitly converting
189+
a non-integral &float; to an &integer; which loses precision.
189190
</simpara>
190191

191192
<example>

language/types/iterable.xml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,19 @@
33
<sect1 xml:id="language.types.iterable">
44
<title>Iterables</title>
55

6-
<para>
7-
<type>Iterable</type> is a built-in compile time type alias for
6+
<simpara>
7+
<type>Iterable</type> is a built-in compile-time type alias for
88
<!-- Need to improve rendering of free-standing type elements in PhD
99
<type class="union"><type>array</type><type>Traversable</type></type>.
1010
-->
1111
<literal>array|Traversable</literal>.
1212
From its introduction in PHP 7.1.0 and prior to PHP 8.2.0,
1313
<type>iterable</type> was a built-in pseudo-type that acted as the
14-
aforementioned type alias and can be used as a type declaration.
14+
aforementioned type alias and could be used as a type declaration.
1515
An iterable type can be used in &foreach; and with
1616
<command>yield from</command> within a
1717
<link linkend="language.generators">generator</link>.
18-
</para>
18+
</simpara>
1919

2020
<note>
2121
<para>

language/types/mixed.xml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,10 @@
1515
Available as of PHP 8.0.0.
1616
</para>
1717

18-
<para>
19-
<type>mixed</type> is, in type theory parlance, the top type.
20-
Meaning every other type is a subtype of it.
21-
</para>
18+
<simpara>
19+
<type>mixed</type> is, in type theory parlance, the top type,
20+
meaning every other type is a subtype of it.
21+
</simpara>
2222

2323
</sect1>
2424
<!-- Keep this comment at the end of the file

language/types/never.xml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,11 @@
1010
<link linkend="language.types.type-system.composite.union">union type</link>
1111
declaration. Available as of PHP 8.1.0.
1212
</para>
13-
<para>
14-
<type>never</type> is, in type theory parlance, the bottom type.
15-
Meaning it is the subtype of every other type and can replace any other
13+
<simpara>
14+
<type>never</type> is, in type theory parlance, the bottom type,
15+
meaning it is the subtype of every other type and can replace any other
1616
return type during inheritance.
17-
</para>
17+
</simpara>
1818

1919
</sect1>
2020
<!-- Keep this comment at the end of the file

language/types/null.xml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@
88
&null;.
99
</para>
1010

11-
<para>
12-
Undefined, and <function>unset</function> variables will resolve to the
11+
<simpara>
12+
Undefined and <function>unset</function> variables resolve to the
1313
value &null;.
14-
</para>
14+
</simpara>
1515

1616
<sect2 xml:id="language.types.null.syntax">
1717
<title>Syntax</title>

language/types/numeric-strings.xml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ var_dump("2E1" == "020"); // true, "2E1" is 2 * (10 ^ 1), or 20
5454
<sect2 xml:id="language.types.numeric-string.conversion">
5555
<title>Strings used in numeric contexts</title>
5656
<para>
57-
When a <type>string</type> needs to be evaluated as number (e.g. arithmetic
57+
When a <type>string</type> needs to be evaluated as a number (e.g. arithmetic
5858
operations, <type>int</type> type declaration, etc.) the following
5959
steps are taken to determine the outcome:
6060

@@ -81,7 +81,7 @@ var_dump("2E1" == "020"); // true, "2E1" is 2 * (10 ^ 1), or 20
8181
</listitem>
8282
<listitem>
8383
<simpara>
84-
The <type>string</type> is not numeric, throw a
84+
If the <type>string</type> is not numeric, throw a
8585
<classname>TypeError</classname>.
8686
</simpara>
8787
</listitem>
@@ -91,12 +91,12 @@ var_dump("2E1" == "020"); // true, "2E1" is 2 * (10 ^ 1), or 20
9191

9292
<sect2 xml:id="language.types.numeric-string.prior">
9393
<title>Behavior prior to PHP 8.0.0</title>
94-
<para>
95-
Prior to PHP 8.0.0, a <type>string</type> was considered numeric only if it
96-
had <emphasis>leading</emphasis> whitespaces, if it had
94+
<simpara>
95+
Prior to PHP 8.0.0, a <type>string</type> was considered numeric if it only
96+
had <emphasis>leading</emphasis> whitespaces. If it had
9797
<emphasis>trailing</emphasis> whitespaces then the string was considered to
9898
be leading numeric.
99-
</para>
99+
</simpara>
100100

101101
<para>
102102
Prior to PHP 8.0.0, when a string was used in a numeric context it would
@@ -110,7 +110,7 @@ var_dump("2E1" == "020"); // true, "2E1" is 2 * (10 ^ 1), or 20
110110
</listitem>
111111
<listitem>
112112
<simpara>
113-
If the string is not numeric, an <constant>E_WARNING</constant> was
113+
If the string was not numeric, an <constant>E_WARNING</constant> was
114114
raised and the value <literal>0</literal> would be returned.
115115
</simpara>
116116
</listitem>

0 commit comments

Comments
 (0)