Skip to content

Commit ad57d99

Browse files
committed
Override: document usage with properties (PHP 8.5)
php/doc-en@9d31699
1 parent db9eb99 commit ad57d99

File tree

1 file changed

+55
-6
lines changed

1 file changed

+55
-6
lines changed

language/predefined/attributes/override.xml

Lines changed: 55 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<!-- $Revision$ -->
3-
<!-- EN-Revision: 7c125c7d4513a66bca7754b418ab56134a581eb1 Maintainer: mumumu Status: ready -->
3+
<!-- EN-Revision: 9d3169961438b1cc12d60183fea68dad8516842d Maintainer: mumumu Status: ready -->
44
<reference xml:id="class.override" role="class" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:xi="http://www.w3.org/2001/XInclude">
55
<title>Override アトリビュート</title>
66
<titleabbrev>Override</titleabbrev>
@@ -11,11 +11,11 @@
1111
&reftitle.intro;
1212
<simpara>
1313
このアトリビュートは、
14-
親クラスのメソッドをオーバーライドしている意図があるか
15-
インターフェイスで定義されたメソッドを実装していることを示します
14+
親クラスのメソッドやプロパティをオーバーライドしている意図があるか
15+
インターフェイスで定義されたプロパティやメソッドを実装していることを示します
1616
</simpara>
1717
<simpara>
18-
親クラス中に同じ名前のメソッドが存在しなかったり
18+
親クラス中に同じ名前のメソッドやプロパティが存在しなかったり
1919
実装されているインターフェイスがない場合は、
2020
コンパイル時にエラーが発生します。
2121
</simpara>
@@ -43,9 +43,33 @@
4343

4444
</section>
4545

46+
<section role="changelog">
47+
&reftitle.changelog;
48+
<informaltable>
49+
<tgroup cols="2">
50+
<thead>
51+
<row>
52+
<entry>&Version;</entry>
53+
<entry>&Description;</entry>
54+
</row>
55+
</thead>
56+
<tbody>
57+
<row>
58+
<entry>8.5.0</entry>
59+
<entry>
60+
<classname>Override</classname> は、
61+
プロパティにも適用できるようになりました。
62+
</entry>
63+
</row>
64+
</tbody>
65+
</tgroup>
66+
</informaltable>
67+
</section>
68+
4669
<section>
4770
&reftitle.examples;
48-
<informalexample>
71+
<example>
72+
<title>メソッドと一緒に使う</title>
4973
<programlisting role="php">
5074
<![CDATA[
5175
<?php
@@ -68,7 +92,32 @@ final class Extended extends Base {
6892
Fatal error: Extended::boo() has #[\Override] attribute, but no matching parent method exists
6993
]]>
7094
</screen>
71-
</informalexample>
95+
</example>
96+
<example>
97+
<title>プロパティと一緒に使う</title>
98+
<programlisting role="php">
99+
<![CDATA[
100+
<?php
101+
102+
class Base {
103+
protected string $foo;
104+
}
105+
106+
final class Extended extends Base {
107+
#[\Override]
108+
protected string $boo;
109+
}
110+
111+
?>
112+
]]>
113+
</programlisting>
114+
&example.outputs.85.similar;
115+
<screen>
116+
<![CDATA[
117+
Fatal error: Extended::$boo has #[\Override] attribute, but no matching parent property exists
118+
]]>
119+
</screen>
120+
</example>
72121
</section>
73122

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

0 commit comments

Comments
 (0)