Skip to content

Commit 6adeedc

Browse files
committed
Update language
1 parent 7c18ff3 commit 6adeedc

File tree

11 files changed

+152
-40
lines changed

11 files changed

+152
-40
lines changed

language/control-structures/match.xml

Lines changed: 3 additions & 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: 22583751fbfdaa3eaa41aeb6470d1343f5cb2c78 Maintainer: mowangjuanzi Status: ready -->
3+
<!-- EN-Revision: 17502ebe0691a84e7d0738c13e8c1061dde98de7 Maintainer: mowangjuanzi Status: ready -->
44
<!-- CREDITS: Luffy, mowangjuanzi -->
55
<sect1 xml:id="control-structures.match" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
66
<title>match</title>
@@ -280,8 +280,8 @@ string(11) "young adult"
280280
$text = 'Bienvenue chez nous';
281281
282282
$result = match (true) {
283-
str_contains($text, 'Welcome') || str_contains($text, 'Hello') => 'en',
284-
str_contains($text, 'Bienvenue') || str_contains($text, 'Bonjour') => 'fr',
283+
str_contains($text, 'Welcome'), str_contains($text, 'Hello') => 'en',
284+
str_contains($text, 'Bienvenue'), str_contains($text, 'Bonjour') => 'fr',
285285
// ...
286286
};
287287

language/oop5/abstract.xml

Lines changed: 3 additions & 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: 984188eb6941dc419f49eed6c1a55a6b749a823d Maintainer: Haohappy Status: ready -->
3+
<!-- EN-Revision: c1f37a6c270aadbbb3da56a3973ffd62197adf2b Maintainer: Haohappy Status: ready -->
44
<!-- CREDITS: mowangjuanzi -->
55
<sect1 xml:id="language.oop5.abstract" xmlns="http://docbook.org/ns/docbook">
66
<title>抽象类</title>
@@ -187,8 +187,8 @@ class C extends A
187187
抽象类上的抽象属性可以为任何挂钩提供实现,必须声明 <literal>get</literal> 或 <literal>set</literal> 但是没有定义(如上例所示)。
188188
</simpara>
189189
<example>
190-
<title>抽象属性示例</title>
191-
<programlisting role="php">
190+
<title>带有挂钩的抽象属性示例</title>
191+
<programlisting role="php" annotations="non-interactive">
192192
<![CDATA[
193193
<?php
194194

language/oop5/anonymous.xml

Lines changed: 2 additions & 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: a058684525563674d49fcfce7ce22d1183ee0a31 Maintainer: daijie Status: ready -->
3+
<!-- EN-Revision: d6f54016d62904cfd8200604aadd5e3f0d9bad97 Maintainer: daijie Status: ready -->
44
<!-- CREDITS: mowangjuanzi -->
55
<sect1 xml:id="language.oop5.anonymous" xmlns="http://docbook.org/ns/docbook">
66
<title>匿名类</title>
@@ -180,9 +180,8 @@ class@anonymous/in/oNi1A0x7f8636ad2021
180180
<programlisting role="php">
181181
<![CDATA[
182182
<?php
183-
184183
// 使用匿名类
185-
$util->setLogger(new readonly class('[DEBUG]') {
184+
var_dump(new readonly class('[DEBUG]') {
186185
public function __construct(private string $prefix)
187186
{
188187
}

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: daijie Status: ready -->
3+
<!-- EN-Revision: 6a3ce2f9a191ad00fdd709c249e6dea16df316e3 Maintainer: daijie Status: ready -->
44
<!-- CREDITS: Luffy, mowangjuanzi -->
55
<sect1 xml:id="language.oop5.changelog" xmlns="http://docbook.org/ns/docbook">
66
<title>OOP 变更日志</title>
@@ -17,6 +17,12 @@
1717
</row>
1818
</thead>
1919
<tbody>
20+
<row>
21+
<entry>8.4.0</entry>
22+
<entry>
23+
新增:支持<link linkend="language.oop5.property-hooks">属性挂钩</link>。
24+
</entry>
25+
</row>
2026
<row>
2127
<entry>8.4.0</entry>
2228
<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: lm92 Status: ready -->
3+
<!-- EN-Revision: 82fc6a1c8670b96f1bd2b40932b6eb19929f4f6f Maintainer: lm92 Status: ready -->
44
<!-- CREDITS: mowangjuanzi, Luffy -->
55
<sect1 xml:id="language.oop5.decon" xmlns="http://docbook.org/ns/docbook">
66
<title>构造函数和析构函数</title>
@@ -176,7 +176,7 @@ class Point {
176176
</note>
177177
<example>
178178
<title>初始化中使用 new</title>
179-
<programlisting role="php">
179+
<programlisting role="php" annotations="non-interactive">
180180
<![CDATA[
181181
<?php
182182
@@ -219,6 +219,9 @@ function test(
219219
<programlisting role="php">
220220
<![CDATA[
221221
<?php
222+
$some_json_string = '{ "id": 1004, "name": "Elephpant" }';
223+
$some_xml_string = "<animal><id>1005</id><name>Elephpant</name></animal>";
224+
222225
class Product {
223226
224227
private ?int $id;
@@ -240,18 +243,19 @@ class Product {
240243
}
241244
242245
public static function fromXml(string $xml): static {
243-
// 自定义代码逻辑。
244-
$data = convert_xml_to_array($xml);
246+
$data = simplexml_load_string($xml);
245247
$new = new static();
246-
$new->id = $data['id'];
247-
$new->name = $data['name'];
248+
$new->id = (int) $data->id;
249+
$new->name = $data->name;
248250
return $new;
249251
}
250252
}
251253
252254
$p1 = Product::fromBasicData(5, 'Widget');
253255
$p2 = Product::fromJson($some_json_string);
254256
$p3 = Product::fromXml($some_xml_string);
257+
258+
var_dump($p1, $p2, $p3);
255259
]]>
256260
</programlisting>
257261
</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: jhdxr Status: ready -->
3+
<!-- EN-Revision: 565bd8b6cf2cae44ae2bc54ef6dbe6ee70ddfefd Maintainer: jhdxr Status: ready -->
44
<!-- CREDITS: mowangjuanzi -->
55
<sect1 xml:id="language.oop5.interfaces" xmlns="http://docbook.org/ns/docbook"
66
xmlns:xlink="http://www.w3.org/1999/xlink">

language/oop5/lazy-objects.xml

Lines changed: 9 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -312,35 +312,26 @@ var_dump($post->id);
312312
对象标记为非延迟。
313313
</member>
314314
<member>
315-
Unlike ghost objects, the properties of the object are not modified at
316-
this stage.
315+
与幽灵对象不同,在此阶段不会修改对象的属性。
317316
</member>
318317
<member>
319-
The factory function is called with the object as its first parameter and
320-
must return a non-lazy instance of a compatible class (see
321-
<methodname>ReflectionClass::newLazyProxy</methodname>).
318+
会将对象作为工厂函数的第一个参数进行调用,并且必须返回兼容类的非延迟实例(参见
319+
<methodname>ReflectionClass::newLazyProxy</methodname>)。
322320
</member>
323321
<member>
324-
The returned instance is referred to as the <emphasis>real
325-
instance</emphasis> and is attached to the proxy.
322+
返回的实例称为<emphasis>真实实例</emphasis>,并附加到代理对象上。
326323
</member>
327324
<member>
328-
The proxy's property values are discarded as though
329-
<function>unset</function> was called.
325+
会丢弃代理对象的属性值,如同调用了 <function>unset</function>。
330326
</member>
331327
</simplelist>
332328
<simpara>
333-
After initialization, accessing any property on the proxy will
334-
yield the same result as accessing the corresponding property on
335-
the real instance; all property accesses on the proxy are forwarded
336-
to the real instance, including declared, dynamic, non-existing, or
337-
properties marked with
338-
<methodname>ReflectionProperty::skipLazyInitialization</methodname> or
339-
<methodname>ReflectionProperty::setRawValueWithoutLazyInitialization</methodname>.
329+
初始化后,访问代理对象上的任何属性将得到与访问真实实例上对应属性相同的结果;访问代理对象上的所有属性都会转发到真实实例,包括已声明、动态、不存在的属性,或使用
330+
<methodname>ReflectionProperty::skipLazyInitialization</methodname> 或
331+
<methodname>ReflectionProperty::setRawValueWithoutLazyInitialization</methodname> 标记的属性。
340332
</simpara>
341333
<simpara>
342-
The proxy object itself is <emphasis>not</emphasis> replaced or substituted
343-
for the real instance.
334+
代理对象本身<emphasis>不会</emphasis>替换(replaced)或替代(substituted)为真实实例。
344335
</simpara>
345336
<simpara>
346337
While the factory receives the proxy as its first parameter, it is

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: Haohappy Status: ready -->
3+
<!-- EN-Revision: d6f54016d62904cfd8200604aadd5e3f0d9bad97 Maintainer: Haohappy Status: ready -->
44
<!-- CREDITS: mowangjuanzi -->
55
<sect1 xml:id="language.oop5.overloading" xmlns="http://docbook.org/ns/docbook">
66
<title>重载</title>
@@ -160,8 +160,6 @@ class PropertyTest {
160160
}
161161
162162
163-
echo "<pre>\n";
164-
165163
$obj = new PropertyTest;
166164
167165
$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: lm92 Status: ready -->
3+
<!-- EN-Revision: d6f54016d62904cfd8200604aadd5e3f0d9bad97 Maintainer: lm92 Status: ready -->
44
<!-- CREDITS: mowangjuanzi -->
55
<sect1 xml:id="language.oop5.paamayim-nekudotayim" xmlns="http://docbook.org/ns/docbook">
66
<title>范围解析操作符 (::)</title>
@@ -54,6 +54,10 @@ echo MyClass::CONST_VALUE;
5454
<programlisting role="php">
5555
<![CDATA[
5656
<?php
57+
class MyClass {
58+
const CONST_VALUE = 'A constant value';
59+
}
60+
5761
class OtherClass extends MyClass
5862
{
5963
public static $my_static = 'static var';

language/operators.xml

Lines changed: 2 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: 16934048f79c6e117cd16a23c09c1b2ea502e284 Maintainer: jhdxr Status: ready -->
3+
<!-- EN-Revision: 2946c8a267734a9e8696e1764f7436e6caa8909c Maintainer: jhdxr Status: ready -->
44
<!-- CREDITS: mowangjuanzi, Luffy -->
55
<chapter xml:id="language.operators" xmlns="http://docbook.org/ns/docbook" annotations="interactive">
66
<title>运算符</title>
@@ -34,6 +34,7 @@
3434
&language.operators.string;
3535
&language.operators.array;
3636
&language.operators.type;
37+
&language.operators.functional;
3738

3839
</chapter>
3940
<!-- Keep this comment at the end of the file

0 commit comments

Comments
 (0)