Skip to content

Commit 3b6b054

Browse files
committed
Wording + Markup and add extending constraint
1 parent 3e57ac1 commit 3b6b054

File tree

1 file changed

+16
-10
lines changed

1 file changed

+16
-10
lines changed

language/oop5/basic.xml

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -130,10 +130,10 @@ Stack trace:
130130
<title>Readonly classes</title>
131131
<para>
132132
As of PHP 8.2.0, a class can be marked with the
133-
<literal>readonly</literal> modifier.
134-
Marking a class as <literal>readonly</literal> will add the
135-
<link linkend="language.oop5.properties.readonly-properties"><literal>readonly</literal> modifier to every declared property</link>,
136-
and prevent the creation of
133+
<modifier>readonly</modifier> modifier.
134+
Marking a class as <modifier>readonly</modifier> will add the
135+
<link linkend="language.oop5.properties.readonly-properties"><modifier>readonly</modifier> modifier</link>
136+
to every declared property, and prevent the creation of
137137
<link linkend="language.oop5.properties.dynamic-properties">dynamic properties</link>.
138138
Moreover, it is impossible to add support for them by using the
139139
<classname>AllowDynamicProperties</classname> attribute. Attempting to do so
@@ -157,8 +157,9 @@ readonly class Foo {
157157
As neither untyped, nor static properties can be marked with the
158158
<literal>readonly</literal> modifier, readonly classes cannot declare
159159
them either:
160-
<example>
161-
<programlisting role="php">
160+
</para>
161+
<example>
162+
<programlisting role="php">
162163
<![CDATA[
163164
<?php
164165
readonly class Foo
@@ -169,8 +170,8 @@ readonly class Foo
169170
// Fatal error: Readonly property Foo::$bar must have type
170171
?>
171172
]]>
172-
</programlisting>
173-
<programlisting role="php">
173+
</programlisting>
174+
<programlisting role="php">
174175
<![CDATA[
175176
<?php
176177
readonly class Foo
@@ -181,8 +182,13 @@ readonly class Foo
181182
// Fatal error: Readonly class Foo cannot declare static properties
182183
?>
183184
]]>
184-
</programlisting>
185-
</example>
185+
</programlisting>
186+
</example>
187+
<para>
188+
A <modifier>readonly</modifier> class can be
189+
<link linkend="language.oop5.basic.extends">extended</link>
190+
if, and only if, the child class is also a
191+
<modifier>readonly</modifier> class.
186192
</para>
187193
</sect3>
188194
</sect2>

0 commit comments

Comments
 (0)