Skip to content

Commit

Permalink
fix double space in various language pages (#4439)
Browse files Browse the repository at this point in the history
  • Loading branch information
PhilDaiguille authored Feb 4, 2025
1 parent 262ca5a commit f4f96ef
Show file tree
Hide file tree
Showing 9 changed files with 138 additions and 138 deletions.
6 changes: 3 additions & 3 deletions language/basic-syntax.xml
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@

<para>
If a file contains only PHP code, it is preferable to omit the PHP closing tag
at the end of the file. This prevents accidental whitespace or new lines
at the end of the file. This prevents accidental whitespace or new lines
being added after the PHP closing tag, which may cause unwanted effects
because PHP will start output buffering when there is no intention from
the programmer to send any output at that point in the script.
Expand All @@ -79,7 +79,7 @@ echo "Last statement";
<title>Escaping from HTML</title>
<para>
Everything outside of a pair of opening and closing tags is ignored by the
PHP parser which allows PHP files to have mixed content. This allows PHP
PHP parser which allows PHP files to have mixed content. This allows PHP
to be embedded in HTML documents, for example to create templates.
<informalexample>
<programlisting role="php">
Expand Down Expand Up @@ -233,7 +233,7 @@ But newline now
</para>
<simpara>
'C' style comments end at the first <literal>*/</literal> encountered.
Make sure you don't nest 'C' style comments. It is easy to make this
Make sure you don't nest 'C' style comments. It is easy to make this
mistake if you are trying to comment out a large block of code.
</simpara>
<para>
Expand Down
4 changes: 2 additions & 2 deletions language/constants.xml
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ echo ANIMALS[1]; // outputs "cat"
<title>Magic constants</title>
<para>
There are a few magical constants that change depending on
where they are used. For example, the value of
where they are used. For example, the value of
<constant>__LINE__</constant> depends on the line that it's
used on in a script. All these "magical" constants are resolved
at compile time, unlike regular constants, which are resolved at runtime.
Expand Down Expand Up @@ -286,7 +286,7 @@ echo ANIMALS[1]; // outputs "cat"
<row xml:id="constant.dir">
<entry><constant>__DIR__</constant></entry>
<entry>
The directory of the file. If used inside an include,
The directory of the file. If used inside an include,
the directory of the included file is returned. This is equivalent
to <literal>dirname(__FILE__)</literal>. This directory name
does not have a trailing slash unless it is the root directory.
Expand Down
68 changes: 34 additions & 34 deletions language/enumerations.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@

<para>
Enumerations, or "Enums", allow a developer to define a custom type that is limited to one
of a discrete number of possible values. That can be especially helpful when defining a
of a discrete number of possible values. That can be especially helpful when defining a
domain model, as it enables "making invalid states unrepresentable."
</para>

<para>
Enums appear in many languages with a variety of different features. In PHP,
Enums are a special kind of object. The Enum itself is a class, and its possible
cases are all single-instance objects of that class. That means Enum cases are
Enums are a special kind of object. The Enum itself is a class, and its possible
cases are all single-instance objects of that class. That means Enum cases are
valid objects and may be used anywhere an object may be used, including type checks.
</para>

Expand Down Expand Up @@ -111,7 +111,7 @@ $a instanceof Suit; // true

<para>
It also means that enum values are never <literal>&lt;</literal> or <literal>&gt;</literal> each other,
since those comparisons are not meaningful on objects. Those comparisons will always return
since those comparisons are not meaningful on objects. Those comparisons will always return
&false; when working with enum values.
</para>

Expand All @@ -121,7 +121,7 @@ $a instanceof Suit; // true
</para>

<para>
All Pure Cases are implemented as instances of their enum type. The enum type is represented internally as a class.
All Pure Cases are implemented as instances of their enum type. The enum type is represented internally as a class.
</para>

<para>
Expand Down Expand Up @@ -177,18 +177,18 @@ enum Suit: string

<para>
A case that has a scalar equivalent is called a Backed Case, as it is "Backed"
by a simpler value. An Enum that contains all Backed Cases is called a "Backed Enum."
A Backed Enum may contain only Backed Cases. A Pure Enum may contain only Pure Cases.
by a simpler value. An Enum that contains all Backed Cases is called a "Backed Enum."
A Backed Enum may contain only Backed Cases. A Pure Enum may contain only Pure Cases.
</para>

<para>
A Backed Enum may be backed by types of <literal>int</literal> or <literal>string</literal>,
and a given enumeration supports only a single type at a time (that is, no union of <literal>int|string</literal>).
If an enumeration is marked as having a scalar equivalent, then all cases must have a unique
scalar equivalent defined explicitly. There are no auto-generated scalar equivalents
(e.g., sequential integers). Backed cases must be unique; two backed enum cases may
not have the same scalar equivalent. However, a constant may refer to a case, effectively
creating an alias. See <link linkend="language.enumerations.constants">Enumeration constants</link>.
scalar equivalent defined explicitly. There are no auto-generated scalar equivalents
(e.g., sequential integers). Backed cases must be unique; two backed enum cases may
not have the same scalar equivalent. However, a constant may refer to a case, effectively
creating an alias. See <link linkend="language.enumerations.constants">Enumeration constants</link>.
</para>

<para>
Expand Down Expand Up @@ -216,7 +216,7 @@ print Suit::Clubs->value;

<para>
In order to enforce the <literal>value</literal> property as read-only, a variable cannot
be assigned as a reference to it. That is, the following throws an error:
be assigned as a reference to it. That is, the following throws an error:
</para>

<programlisting role="php">
Expand All @@ -238,25 +238,25 @@ $ref = &$suit->value;
<simplelist>
<member>
<literal>from(int|string): self</literal> will take a scalar and return the corresponding
Enum Case. If one is not found, it will throw a <classname>ValueError</classname>. This is mainly
Enum Case. If one is not found, it will throw a <classname>ValueError</classname>. This is mainly
useful in cases where the input scalar is trusted and a missing enum value should be
considered an application-stopping error.
</member>
<member>
<literal>tryFrom(int|string): ?self</literal> will take a scalar and return the
corresponding Enum Case. If one is not found, it will return <literal>null</literal>.
corresponding Enum Case. If one is not found, it will return <literal>null</literal>.
This is mainly useful in cases where the input scalar is untrusted and the caller wants
to implement their own error handling or default-value logic.
</member>
</simplelist>

<para>
The <literal>from()</literal> and <literal>tryFrom()</literal> methods follow standard
weak/strong typing rules. In weak typing mode, passing an integer or string is acceptable
and the system will coerce the value accordingly. Passing a float will also work and be
coerced. In strict typing mode, passing an integer to <literal>from()</literal> on a
weak/strong typing rules. In weak typing mode, passing an integer or string is acceptable
and the system will coerce the value accordingly. Passing a float will also work and be
coerced. In strict typing mode, passing an integer to <literal>from()</literal> on a
string-backed enum (or vice versa) will result in a <classname>TypeError</classname>,
as will a float in all circumstances. All other parameter types will throw a TypeError
as will a float in all circumstances. All other parameter types will throw a TypeError
in both modes.
</para>

Expand Down Expand Up @@ -337,7 +337,7 @@ print Suit::Diamonds->shape(); // prints "Rectangle"

<para>
In this example, all four instances of <literal>Suit</literal> have two methods,
<literal>color()</literal> and <literal>shape()</literal>. As far as calling code
<literal>color()</literal> and <literal>shape()</literal>. As far as calling code
and type checks are concerned, they behave exactly the same as any other object instance.
</para>

Expand Down Expand Up @@ -447,8 +447,8 @@ final class Suit implements UnitEnum, Colorful
<title>Enumeration static methods</title>

<para>
Enumerations may also have static methods. The use for static methods on the
enumeration itself is primarily for alternative constructors. E.g.:
Enumerations may also have static methods. The use for static methods on the
enumeration itself is primarily for alternative constructors. E.g.:
</para>

<programlisting role="php">
Expand Down Expand Up @@ -513,7 +513,7 @@ enum Size

<para>Enumerations may leverage traits, which will behave the same as on classes.
The caveat is that traits <literal>use</literal>d in an enum must not contain properties.
They may only include methods, static methods, and constants. A trait with properties will
They may only include methods, static methods, and constants. A trait with properties will
result in a fatal error.
</para>

Expand Down Expand Up @@ -649,8 +649,8 @@ $foo = new Foo();
<member>Enums may implement any number of interfaces.</member>
<member>
Enums and cases may have <link linkend="language.attributes">attributes</link> attached
to them. The <constant>TARGET_CLASS</constant> target
filter includes Enums themselves. The <constant>TARGET_CLASS_CONST</constant> target filter
to them. The <constant>TARGET_CLASS</constant> target
filter includes Enums themselves. The <constant>TARGET_CLASS_CONST</constant> target filter
includes Enum Cases.
</member>
<member>
Expand All @@ -662,14 +662,14 @@ $foo = new Foo();

<para>
The <literal>::class</literal> magic constant on an Enum type evaluates to the type
name including any namespace, exactly the same as an object. The <literal>::class</literal>
name including any namespace, exactly the same as an object. The <literal>::class</literal>
magic constant on a Case instance also evaluates to the Enum type, as it is an
instance of that type.
</para>

<para>
Additionally, enum cases may not be instantiated directly with <literal>new</literal>, nor with
<methodname>ReflectionClass::newInstanceWithoutConstructor</methodname> in reflection. Both will result in an error.
<methodname>ReflectionClass::newInstanceWithoutConstructor</methodname> in reflection. Both will result in an error.
</para>

<programlisting role="php">
Expand All @@ -691,7 +691,7 @@ $horseshoes = (new ReflectionClass(Suit::class))->newInstanceWithoutConstructor(

<para>
Both Pure Enums and Backed Enums implement an internal interface named
<interfacename>UnitEnum</interfacename>. <literal>UnitEnum</literal> includes a static method
<interfacename>UnitEnum</interfacename>. <literal>UnitEnum</literal> includes a static method
<literal>cases()</literal>. <literal>cases()</literal> returns a packed array of
all defined Cases in the order of declaration.
</para>
Expand All @@ -713,9 +713,9 @@ Suit::cases();
<title>Serialization</title>

<para>
Enumerations are serialized differently from objects. Specifically, they have a new serialization code,
<literal>"E"</literal>, that specifies the name of the enum case. The deserialization routine is then
able to use that to set a variable to the existing singleton value. That ensures that:
Enumerations are serialized differently from objects. Specifically, they have a new serialization code,
<literal>"E"</literal>, that specifies the name of the enum case. The deserialization routine is then
able to use that to set a variable to the existing singleton value. That ensures that:
</para>

<programlisting role="php">
Expand All @@ -735,9 +735,9 @@ print serialize(Suit::Hearts);
value a warning will be issued and &false; returned.</para>

<para>
If a Pure Enum is serialized to JSON, an error will be thrown. If a Backed Enum
If a Pure Enum is serialized to JSON, an error will be thrown. If a Backed Enum
is serialized to JSON, it will be represented by its scalar value only, in the
appropriate type. The behavior of both may be overridden by implementing
appropriate type. The behavior of both may be overridden by implementing
<classname>JsonSerializable</classname>.
</para>

Expand Down Expand Up @@ -900,7 +900,7 @@ function query($fields, $filter, SortOrder $order = SortOrder::Asc)
<para>
The <literal>query()</literal> function can now proceed safe in the knowledge that
<literal>$order</literal> is guaranteed to be either <literal>SortOrder::Asc</literal>
or <literal>SortOrder::Desc</literal>. Any other value would have resulted in a
or <literal>SortOrder::Desc</literal>. Any other value would have resulted in a
<classname>TypeError</classname>, so no further error checking or testing is needed.
</para>
</example>
Expand Down Expand Up @@ -939,7 +939,7 @@ enum UserStatus: string
<para>
In this example, a user's status may be one of, and exclusively, <literal>UserStatus::Pending</literal>,
<literal>UserStatus::Active</literal>, <literal>UserStatus::Suspended</literal>, or
<literal>UserStatus::CanceledByUser</literal>. A function can type a parameter against
<literal>UserStatus::CanceledByUser</literal>. A function can type a parameter against
<literal>UserStatus</literal> and then only accept those four values, period.
</para>

Expand Down
10 changes: 5 additions & 5 deletions language/exceptions.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@
<title>Exceptions</title>
<para>
PHP has an exception model similar to that of other programming
languages. An exception can be &throw;n, and caught ("&catch;ed") within
languages. An exception can be &throw;n, and caught ("&catch;ed") within
PHP. Code may be surrounded in a &try; block, to facilitate the catching
of potential exceptions. Each &try; must have at least one corresponding
&catch; or &finally; block.
</para>
<para>
If an exception is thrown and its current function scope has no &catch;
block, the exception will "bubble up" the call stack to the calling
function until it finds a matching &catch; block. All &finally; blocks it encounters
function until it finds a matching &catch; block. All &finally; blocks it encounters
along the way will be executed. If the call stack is unwound all the way to the
global scope without encountering a matching &catch; block, the program will
terminate with a fatal error unless a global exception handler has been set.
Expand All @@ -29,7 +29,7 @@
<sect1 annotations="chunk:false" xml:id="language.exceptions.catch">
<title><literal>catch</literal></title>
<para>
A &catch; block defines how to respond to a thrown exception. A &catch;
A &catch; block defines how to respond to a thrown exception. A &catch;
block defines one or more types of exception or error it can handle, and
optionally a variable to which to assign the exception. (The variable was
required prior to PHP 8.0.0.) The first &catch; block a thrown exception
Expand Down Expand Up @@ -85,9 +85,9 @@
<title>Global exception handler</title>
<para>
If an exception is allowed to bubble up to the global scope, it may be caught
by a global exception handler if set. The <function>set_exception_handler</function>
by a global exception handler if set. The <function>set_exception_handler</function>
function can set a function that will be called in place of a &catch; block if no
other block is invoked. The effect is essentially the same as if the entire program
other block is invoked. The effect is essentially the same as if the entire program
were wrapped in a &try;-&catch; block with that function as the &catch;.
</para>
</sect1>
Expand Down
Loading

0 comments on commit f4f96ef

Please sign in to comment.