Skip to content

Commit 9cc604e

Browse files
CrellGirgias
andauthored
Tweaks and nitpicks from Girgas
Co-authored-by: Gina Peter Banyard <[email protected]>
1 parent 7c0d3ca commit 9cc604e

File tree

3 files changed

+12
-10
lines changed

3 files changed

+12
-10
lines changed

language/oop5/interfaces.xml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -92,15 +92,15 @@
9292
<sect2 xml:id="language.oop5.interfaces.properties">
9393
<title>Properties</title>
9494
<para>
95-
As of PHP 8.4, interfaces may also declare properties. If they do, the declaration must specify if the
95+
As of PHP 8.4.0, interfaces may also declare properties. If they do, the declaration must specify if the
9696
property is to be readable, writeable, or both. The interface declaration applies only to public read
9797
and write access.
9898
</para>
9999
<para>
100100
An class may satisfy an interface property in multiple ways. It may define a public property. It may
101101
define a public <link linkend="language.oop5.property-hooks.virtual">virtual property</link> that implements
102-
only the corresponding hook. Or a read property may be satisfied by a <literal>readonly</literal> property. An interface property that is settable may not
103-
be <literal>readonly</literal>, however.
102+
only the corresponding hook. Or a read property may be satisfied by a <literal>readonly</literal> property.
103+
However, an interface property that is settable may not be <literal>readonly</literal>.
104104
</para>
105105
<example>
106106
<title>Interface properties example</title>
@@ -141,8 +141,8 @@ class C2 implements I
141141
private string $all = '';
142142
143143
// Uses only a get hook to create a virtual property.
144-
// This satisfies the "public get" requirement. It is not
145-
// writeable, but that is not required by the interface.
144+
// This satisfies the "public get" requirement.
145+
// It is not writeable, but that is not required by the interface.
146146
public string $readable { get => strtoupper($this->writeable); }
147147
148148
// The interface only requires the property be settable,

language/oop5/property-hooks.xml

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ print $example->foo;
7171
</programlisting>
7272
</example>
7373
<para>
74-
The <varname>$foo</varname> property ends in <literal>{}</literal>, rather than a semicolon.
74+
The <varname>foo</varname> property ends in <literal>{}</literal>, rather than a semicolon.
7575
That indicates the presence of hooks. Both a <literal>get</literal> and <literal>set</literal>
7676
hook are defined, although it is allowed to define only one or the other. Both hooks have a body,
7777
denoted by <literal>{}</literal>, that may contain arbitrary code.
@@ -81,7 +81,7 @@ print $example->foo;
8181
using the same syntax as a method. The type must be either the same as the type of the property,
8282
or <link linkend="language.oop5.variance.contravariance">contravariant</link> (wider) to it.
8383
For instance, a property of type <type>string</type> could
84-
have a <literal>set</literal> hook that accepts <type>string|Stringable</type>,
84+
have a <literal>set</literal> hook that accepts <type class="union"><type>string</type><type>Stringable</type></type>,
8585
but not one that only accepts <type>array</type>.
8686
</para>
8787
<para>
@@ -254,7 +254,8 @@ $s->area = 30; // Error, as there is no set operation defined.
254254
</para>
255255
<para>
256256
The most notable implication of this is that non-trivial hooks may sub-call to an
257-
arbitrarily complex method if they wish.</para>
257+
arbitrarily complex method if they wish.
258+
</para>
258259
<example>
259260
<title>Calling a method from a hook</title>
260261
<programlisting role="php">
@@ -319,7 +320,7 @@ class Person {
319320
<example>
320321
<title>Final hooks</title>
321322
<programlisting role="php">
322-
<![CDATA[
323+
<![CDATA[
323324
<?php
324325
class User
325326
{

language/oop5/variance.xml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,8 @@ Fatal error: Uncaught TypeError: Argument 1 passed to Animal::eat() must be an i
250250
and "set" operations must be contravariant. The only way for a property to satisfy both requirements is to be invariant.
251251
</para>
252252
<para>
253-
Since PHP 8.4, with the addition of abstract properties (on an interface or abstract class) and <link linkend="language.oop5.property-hooks.virtual">virtual properties</link>,
253+
As of PHP 8.4.0, with the addition of abstract properties (on an interface or abstract class) and
254+
<link linkend="language.oop5.property-hooks.virtual">virtual properties</link>,
254255
it is possible to declare a property that has only a get or set operation.
255256
As a result, abstract properties or virtual properties that have only a "get" operation required may be covariant.
256257
Similarly, an abstract property or virtual property that has only a "set" operation required may be contravariant.

0 commit comments

Comments
 (0)