@@ -130,10 +130,10 @@ Stack trace:
130
130
<title >Readonly classes</title >
131
131
<para >
132
132
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
137
137
<link linkend =" language.oop5.properties.dynamic-properties" >dynamic properties</link >.
138
138
Moreover, it is impossible to add support for them by using the
139
139
<classname >AllowDynamicProperties</classname > attribute. Attempting to do so
@@ -157,8 +157,9 @@ readonly class Foo {
157
157
As neither untyped, nor static properties can be marked with the
158
158
<literal >readonly</literal > modifier, readonly classes cannot declare
159
159
them either:
160
- <example >
161
- <programlisting role =" php" >
160
+ </para >
161
+ <example >
162
+ <programlisting role =" php" >
162
163
<![CDATA[
163
164
<?php
164
165
readonly class Foo
@@ -169,8 +170,8 @@ readonly class Foo
169
170
// Fatal error: Readonly property Foo::$bar must have type
170
171
?>
171
172
]]>
172
- </programlisting >
173
- <programlisting role =" php" >
173
+ </programlisting >
174
+ <programlisting role =" php" >
174
175
<![CDATA[
175
176
<?php
176
177
readonly class Foo
@@ -181,8 +182,13 @@ readonly class Foo
181
182
// Fatal error: Readonly class Foo cannot declare static properties
182
183
?>
183
184
]]>
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.
186
192
</para >
187
193
</sect3 >
188
194
</sect2 >
0 commit comments