Skip to content

Commit cf18c9e

Browse files
committed
Override: document usage with properties (PHP 8.5)
1 parent 239683e commit cf18c9e

File tree

1 file changed

+54
-6
lines changed

1 file changed

+54
-6
lines changed

language/predefined/attributes/override.xml

Lines changed: 54 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,12 @@
88
<section xml:id="override.intro">
99
&reftitle.intro;
1010
<simpara>
11-
This attribute is used to indicate that a method is intended
12-
to override a method of a parent class or that it implements
13-
a method defined in an interface.
11+
This attribute is used to indicate that a method or a property is intended
12+
to override a method or a property of a parent class or that it implements
13+
a method or a property defined in an interface.
1414
</simpara>
1515
<simpara>
16-
If no method with the same name exists in a parent class or
16+
If no method or property with the same name exists in a parent class or
1717
in an implemented interface a compile-time error will be
1818
emitted.
1919
</simpara>
@@ -41,9 +41,32 @@
4141

4242
</section>
4343

44+
<section role="changelog">
45+
&reftitle.changelog;
46+
<informaltable>
47+
<tgroup cols="2">
48+
<thead>
49+
<row>
50+
<entry>&Version;</entry>
51+
<entry>&Description;</entry>
52+
</row>
53+
</thead>
54+
<tbody>
55+
<row>
56+
<entry>8.5.0</entry>
57+
<entry>
58+
<classname>Override</classname> can be applied to properties.
59+
</entry>
60+
</row>
61+
</tbody>
62+
</tgroup>
63+
</informaltable>
64+
</section>
65+
4466
<section>
4567
&reftitle.examples;
46-
<informalexample>
68+
<example>
69+
<title>Usage with methods</title>
4770
<programlisting role="php">
4871
<![CDATA[
4972
<?php
@@ -66,7 +89,32 @@ final class Extended extends Base {
6689
Fatal error: Extended::boo() has #[\Override] attribute, but no matching parent method exists
6790
]]>
6891
</screen>
69-
</informalexample>
92+
</example>
93+
<example>
94+
<title>Usage with properties</title>
95+
<programlisting role="php">
96+
<![CDATA[
97+
<?php
98+
99+
class Base {
100+
protected string $foo;
101+
}
102+
103+
final class Extended extends Base {
104+
#[\Override]
105+
protected string $boo;
106+
}
107+
108+
?>
109+
]]>
110+
</programlisting>
111+
&example.outputs.85.similar;
112+
<screen>
113+
<![CDATA[
114+
Fatal error: Extended::$boo has #[\Override] attribute, but no matching parent property exists
115+
]]>
116+
</screen>
117+
</example>
70118
</section>
71119

72120
<section xml:id="override.seealso">

0 commit comments

Comments
 (0)