1
1
<?xml version =" 1.0" encoding =" utf-8" ?>
2
2
<!-- $Revision$ -->
3
- <!-- EN-Revision: 7c125c7d4513a66bca7754b418ab56134a581eb1 Maintainer: mumumu Status: ready -->
3
+ <!-- EN-Revision: 9d3169961438b1cc12d60183fea68dad8516842d Maintainer: mumumu Status: ready -->
4
4
<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" >
5
5
<title >Override アトリビュート</title >
6
6
<titleabbrev >Override</titleabbrev >
11
11
&reftitle.intro;
12
12
<simpara >
13
13
このアトリビュートは、
14
- 親クラスのメソッドをオーバーライドしている意図があるか 、
15
- インターフェイスで定義されたメソッドを実装していることを示します 。
14
+ 親クラスのメソッドやプロパティをオーバーライドしている意図があるか 、
15
+ インターフェイスで定義されたプロパティやメソッドを実装していることを示します 。
16
16
</simpara >
17
17
<simpara >
18
- 親クラス中に同じ名前のメソッドが存在しなかったり 、
18
+ 親クラス中に同じ名前のメソッドやプロパティが存在しなかったり 、
19
19
実装されているインターフェイスがない場合は、
20
20
コンパイル時にエラーが発生します。
21
21
</simpara >
43
43
44
44
</section >
45
45
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
+
46
69
<section >
47
70
&reftitle.examples;
48
- <informalexample >
71
+ <example >
72
+ <title >メソッドと一緒に使う</title >
49
73
<programlisting role =" php" >
50
74
<![CDATA[
51
75
<?php
@@ -68,7 +92,32 @@ final class Extended extends Base {
68
92
Fatal error: Extended::boo() has #[\Override] attribute, but no matching parent method exists
69
93
]]>
70
94
</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 >
72
121
</section >
73
122
74
123
<section xml : id =" override.seealso" >
0 commit comments