Skip to content

Commit d836ae2

Browse files
committed
[language/oop5/*.xml] sync with en.
1 parent 45707f5 commit d836ae2

File tree

10 files changed

+165
-70
lines changed

10 files changed

+165
-70
lines changed

language/oop5/changelog.xml

Lines changed: 7 additions & 1 deletion
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: c0fa5077c8862405942d8aac7360c5169558b59b Maintainer: takagi Status: ready -->
3+
<!-- EN-Revision: 6a3ce2f9a191ad00fdd709c249e6dea16df316e3 Maintainer: takagi Status: ready -->
44
<!-- CREDITS: mumumu -->
55

66
<sect1 xml:id="language.oop5.changelog" xmlns="http://docbook.org/ns/docbook">
@@ -19,6 +19,12 @@
1919
</row>
2020
</thead>
2121
<tbody>
22+
<row>
23+
<entry>8.4.0</entry>
24+
<entry>
25+
<link linkend="language.oop5.property-hooks">プロパティフック</link> がサポートされました。
26+
</entry>
27+
</row>
2228
<row>
2329
<entry>8.4.0</entry>
2430
<entry>

language/oop5/decon.xml

Lines changed: 10 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: 376d3f9c2ef7fcd64d8b8503d552013acefb8b5b Maintainer: hirokawa Status: ready -->
3+
<!-- EN-Revision: 82fc6a1c8670b96f1bd2b40932b6eb19929f4f6f Maintainer: hirokawa Status: ready -->
44
<!-- CREDITS: shimooka,mumumu -->
55

66
<sect1 xml:id="language.oop5.decon" xmlns="http://docbook.org/ns/docbook">
@@ -215,7 +215,7 @@ class Point {
215215
</note>
216216
<example>
217217
<title>初期化時に new キーワードを使う</title>
218-
<programlisting role="php">
218+
<programlisting role="php" annotations="non-interactive">
219219
<![CDATA[
220220
<?php
221221
@@ -259,6 +259,9 @@ function test(
259259
<programlisting role="php">
260260
<![CDATA[
261261
<?php
262+
$some_json_string = '{ "id": 1004, "name": "Elephpant" }';
263+
$some_xml_string = "<animal><id>1005</id><name>Elephpant</name></animal>";
264+
262265
class Product {
263266
264267
private ?int $id;
@@ -280,18 +283,19 @@ class Product {
280283
}
281284
282285
public static function fromXml(string $xml): static {
283-
// Custom logic here.
284-
$data = convert_xml_to_array($xml);
286+
$data = simplexml_load_string($xml);
285287
$new = new static();
286-
$new->id = $data['id'];
287-
$new->name = $data['name'];
288+
$new->id = (int) $data->id;
289+
$new->name = $data->name;
288290
return $new;
289291
}
290292
}
291293
292294
$p1 = Product::fromBasicData(5, 'Widget');
293295
$p2 = Product::fromJson($some_json_string);
294296
$p3 = Product::fromXml($some_xml_string);
297+
298+
var_dump($p1, $p2, $p3);
295299
]]>
296300
</programlisting>
297301
</example>

language/oop5/interfaces.xml

Lines changed: 1 addition & 1 deletion
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: 0c2a0d736df56dd0f3a1b88bd6ce7c975c38285a Maintainer: hirokawa Status: ready -->
3+
<!-- EN-Revision: 565bd8b6cf2cae44ae2bc54ef6dbe6ee70ddfefd Maintainer: hirokawa Status: ready -->
44
<!-- CREDITS: shimooka,takagi,mumumu -->
55

66
<sect1 xml:id="language.oop5.interfaces" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">

language/oop5/late-static-bindings.xml

Lines changed: 77 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<!-- $Revision$ -->
3-
<!-- EN-Revision: 9ee9eccf455188ab6eb352194eb6f9eb99e15606 Maintainer: takagi Status: ready -->
4-
3+
<!-- EN-Revision: 009f215fc983eeded6161676bcffdd8cf3b6b080 Maintainer: takagi Status: ready -->
54
<sect1 xml:id="language.oop5.late-static-bindings" xmlns="http://docbook.org/ns/docbook">
65
<title>遅延静的束縛 (Late Static Bindings)</title>
76
<para>
@@ -47,22 +46,30 @@
4746
<programlisting role="php">
4847
<![CDATA[
4948
<?php
50-
class A {
51-
public static function who() {
49+
50+
class A
51+
{
52+
public static function who()
53+
{
5254
echo __CLASS__;
5355
}
54-
public static function test() {
56+
57+
public static function test()
58+
{
5559
self::who();
5660
}
5761
}
5862
59-
class B extends A {
60-
public static function who() {
63+
class B extends A
64+
{
65+
public static function who()
66+
{
6167
echo __CLASS__;
6268
}
6369
}
6470
6571
B::test();
72+
6673
?>
6774
]]>
6875
</programlisting>
@@ -94,22 +101,30 @@ A
94101
<programlisting role="php">
95102
<![CDATA[
96103
<?php
97-
class A {
98-
public static function who() {
104+
105+
class A
106+
{
107+
public static function who()
108+
{
99109
echo __CLASS__;
100110
}
101-
public static function test() {
111+
112+
public static function test()
113+
{
102114
static::who(); // これで、遅延静的束縛が行われます
103115
}
104116
}
105117
106-
class B extends A {
107-
public static function who() {
118+
class B extends A
119+
{
120+
public static function who()
121+
{
108122
echo __CLASS__;
109123
}
110124
}
111125
112126
B::test();
127+
113128
?>
114129
]]>
115130
</programlisting>
@@ -133,43 +148,55 @@ B
133148
<programlisting role="php">
134149
<![CDATA[
135150
<?php
136-
class A {
137-
private function foo() {
138-
echo "success!\n";
151+
152+
class A
153+
{
154+
private function foo()
155+
{
156+
echo "Success!\n";
139157
}
140-
public function test() {
158+
159+
public function test()
160+
{
141161
$this->foo();
142162
static::foo();
143163
}
144164
}
145165
146-
class B extends A {
147-
/* foo() が B にコピーされるので、メソッドのスコープは A のままとなり、
148-
* コールは成功します */
166+
class B extends A
167+
{
168+
/* foo() が B にコピーされるので、メソッドのスコープは A のままとなり、
169+
* コールは成功します */
149170
}
150171
151-
class C extends A {
152-
private function foo() {
172+
class C extends A
173+
{
174+
private function foo()
175+
{
153176
/* もとのメソッドが置き換えられるので、新しいメソッドのスコープは C となります */
154177
}
155178
}
156179
157180
$b = new B();
158181
$b->test();
182+
159183
$c = new C();
160-
$c->test(); //fails
184+
try {
185+
$c->test();
186+
} catch (Error $e) {
187+
echo $e->getMessage();
188+
}
189+
161190
?>
162191
]]>
163192
</programlisting>
164193
&example.outputs;
165194
<screen>
166195
<![CDATA[
167-
success!
168-
success!
169-
success!
170-
171-
172-
Fatal error: Call to private method C::foo() from context 'A' in /tmp/test.php on line 9
196+
Success!
197+
Success!
198+
Success!
199+
Call to private method C::foo() from scope A
173200
]]>
174201
</screen>
175202
</example>
@@ -184,34 +211,45 @@ Fatal error: Call to private method C::foo() from context 'A' in /tmp/test.php
184211
<programlisting role="php">
185212
<![CDATA[
186213
<?php
187-
class A {
188-
public static function foo() {
214+
215+
class A
216+
{
217+
public static function foo()
218+
{
189219
static::who();
190220
}
191221
192-
public static function who() {
193-
echo __CLASS__."\n";
222+
public static function who()
223+
{
224+
echo __CLASS__ . "\n";
194225
}
195226
}
196227
197-
class B extends A {
198-
public static function test() {
228+
class B extends A
229+
{
230+
public static function test()
231+
{
199232
A::foo();
200233
parent::foo();
201234
self::foo();
202235
}
203236
204-
public static function who() {
205-
echo __CLASS__."\n";
237+
public static function who()
238+
{
239+
echo __CLASS__ . "\n";
206240
}
207241
}
208-
class C extends B {
209-
public static function who() {
210-
echo __CLASS__."\n";
242+
243+
class C extends B
244+
{
245+
public static function who()
246+
{
247+
echo __CLASS__ . "\n";
211248
}
212249
}
213250
214251
C::test();
252+
215253
?>
216254
]]>
217255
</programlisting>

language/oop5/lazy-objects.xml

Lines changed: 11 additions & 4 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: c0fa5077c8862405942d8aac7360c5169558b59b Maintainer: KentarouTakeda Status: ready -->
3+
<!-- EN-Revision: 617cc59b5902de0cadd32883b72b113bf62cf1b6 Maintainer: KentarouTakeda Status: ready -->
44
<!-- Credits: KentarouTakeda -->
55
<sect1 xml:id="language.oop5.lazy-objects" xmlns="http://docbook.org/ns/docbook">
66
<title>レイジーオブジェクト</title>
@@ -26,6 +26,13 @@
2626
持つからです。
2727
</simpara>
2828

29+
<note>
30+
<title>バージョン情報</title>
31+
<simpara>
32+
レイジーオブジェクトは、PHP 8.4 で実装されました。
33+
</simpara>
34+
</note>
35+
2936
<sect2 xml:id="language.oop5.lazy-objects.creation">
3037
<title>レイジーオブジェクトの作成</title>
3138

@@ -141,9 +148,9 @@ int(1)
141148
class BlogPost
142149
{
143150
public function __construct(
144-
private int $id,
145-
private string $title,
146-
private string $content,
151+
public int $id,
152+
public string $title,
153+
public string $content,
147154
) { }
148155
}
149156

language/oop5/overloading.xml

Lines changed: 1 addition & 3 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: 2ab7e9d763666526942ed4477c4f876beb160892 Maintainer: takagi Status: ready -->
3+
<!-- EN-Revision: d6f54016d62904cfd8200604aadd5e3f0d9bad97 Maintainer: takagi Status: ready -->
44
<!-- CREDITS: hirokawa,shimooka,mumumu -->
55

66
<sect1 xml:id="language.oop5.overloading" xmlns="http://docbook.org/ns/docbook">
@@ -193,8 +193,6 @@ class PropertyTest
193193
}
194194
195195
196-
echo "<pre>\n";
197-
198196
$obj = new PropertyTest;
199197
200198
$obj->a = 1;

language/oop5/paamayim-nekudotayim.xml

Lines changed: 5 additions & 1 deletion
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: e3d36be7d64f1fd47612a91297c7f6d75e4e50c7 Maintainer: takagi Status: ready -->
3+
<!-- EN-Revision: d6f54016d62904cfd8200604aadd5e3f0d9bad97 Maintainer: takagi Status: ready -->
44
<!-- CREDITS: hirokawa -->
55

66
<sect1 xml:id="language.oop5.paamayim-nekudotayim" xmlns="http://docbook.org/ns/docbook">
@@ -66,6 +66,10 @@ echo MyClass::CONST_VALUE;
6666
<programlisting role="php">
6767
<![CDATA[
6868
<?php
69+
class MyClass {
70+
const CONST_VALUE = 'A constant value';
71+
}
72+
6973
class OtherClass extends MyClass
7074
{
7175
public static $my_static = 'static var';

0 commit comments

Comments
 (0)