Skip to content

Commit eb5d702

Browse files
committed
Update appendices
1 parent 6ca84d0 commit eb5d702

File tree

10 files changed

+250
-253
lines changed

10 files changed

+250
-253
lines changed

appendices/migration70/changed-functions.xml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<!-- $Revision$ -->
3-
<!-- EN-Revision: 4279863b96f74295fb6bd2d44e34270a71fb9537 Maintainer: Avenger Status: ready -->
3+
<!-- EN-Revision: 976425d4f6eec32448be3cc22ec063015921b753 Maintainer: Avenger Status: ready -->
4+
<!-- CREDITS: mowangjuanzi -->
45
<sect1 xml:id="migration70.changed-functions">
56
<title>变更的函数</title>
67

@@ -43,7 +44,7 @@
4344
<listitem>
4445
<simpara>
4546
<function>setlocale</function> 函数不再接受 <parameter>category</parameter>
46-
传入字符串。应当使用 <constant>LC_*</constant> 常量。
47+
传入字符串。应当使用 <constant>LC_<replaceable>*</replaceable></constant> 常量。
4748
</simpara>
4849
</listitem>
4950
<listitem>

appendices/migration70/incompatible/removed-functions.xml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<!-- $Revision$ -->
3-
<!-- EN-Revision: 8f5f6a52c0d25a42a069c6c1cff4effb68fb379c Maintainer: avenger Status: ready -->
3+
<!-- EN-Revision: 976425d4f6eec32448be3cc22ec063015921b753 Maintainer: avenger Status: ready -->
4+
<!-- CREDITS: mowangjuanzi -->
45
<sect2 xml:id="migration70.incompatible.removed-functions">
56
<title>移除的函数</title>
67

@@ -38,8 +39,8 @@
3839

3940
<para>
4041
此外,已废弃的 <function>mcrypt_ecb</function>,<function>mcrypt_cbc</function>、<function>mcrypt_cfb</function> 和
41-
<function>mcrypt_ofb</function> 函数已被移除,请配合恰当的 <constant>MCRYPT_MODE_*</constant> 常量来使用 <function>mcrypt_decrypt</function> 进行代替。
42-
42+
<function>mcrypt_ofb</function> 函数已被移除,请配合恰当的 <constant>MCRYPT_MODE_<replaceable>*</replaceable></constant>
43+
常量来使用 <function>mcrypt_decrypt</function> 进行代替。
4344
</para>
4445
</sect3>
4546

appendices/migration74/windows-support.xml

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<!-- $Revision: 348541 $ -->
3-
<!-- EN-Revision: 1352dd77d723cb732484d0ae6aa1fc9a81974983 Maintainer: Avenger Status: ready -->
3+
<!-- EN-Revision: eee245cdbd89dc2fd908285f588e3b9e055924e5 Maintainer: Avenger Status: ready -->
44
<!-- CREDITS: mowangjuanzi -->
55
<sect1 xml:id="migration74.windows-support" xmlns:xlink="http://www.w3.org/1999/xlink">
66
<title>Windows 支持</title>
@@ -15,7 +15,13 @@
1515
<sect2 xml:id="migration74.windows-support.other">
1616
<title>CTRL 处理</title>
1717
<para>
18-
控制台上的 CTRL+C 和 CTRL+BREAK 可以通过 <function>sapi_windows_set_ctrl_handler</function>
18+
控制台上的 <keycombo action='simul'>
19+
<keycap>CTRL</keycap>
20+
<keycap>C</keycap>
21+
</keycombo> 和 <keycombo action='simul'>
22+
<keycap>CTRL</keycap>
23+
<keycap>BREAK</keycap>
24+
</keycombo> 可以通过 <function>sapi_windows_set_ctrl_handler</function>
1925
设置处理函数来捕获。
2026
</para>
2127
<para>

appendices/migration80/other-changes.xml

Lines changed: 2 additions & 2 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: 4c41f6fa0ebe4afe8b7a3468e7e26dfd0c0e4131 Maintainer: avenger Status: ready -->
3+
<!-- EN-Revision: 976425d4f6eec32448be3cc22ec063015921b753 Maintainer: avenger Status: ready -->
44
<!-- CREDITS: mowangjuanzi -->
55
<sect1 xml:id="migration80.other-changes" xmlns:xlink="http://www.w3.org/1999/xlink">
66
<title>其他变更</title>
@@ -72,7 +72,7 @@
7272
<methodname>ZipArchive::addEmptyDir</methodname>、<methodname>ZipArchive::addFile</methodname>、<methodname>ZipArchive::addFromString</methodname>
7373
方法新增 <parameter>flags</parameter> 参数。
7474

75-
可用于名称编码(<constant>ZipArchive::FL_ENC_*</constant>)与条目(entry)替换(<constant>ZipArchive::FL_OVERWRITE</constant>)。
75+
可用于名称编码(<constant>ZipArchive::FL_ENC_<replaceable>*</replaceable></constant>)与条目(entry)替换(<constant>ZipArchive::FL_OVERWRITE</constant>)。
7676
</para>
7777
</listitem>
7878
<listitem>

appendices/migration84/constants.xml

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<?xml version="1.0" encoding="utf-8"?>
2-
<!-- EN-Revision: d64e811eac61a5c7c744312d8bc6e2244de81488 Maintainer: mowangjuanzi Status: ready -->
2+
<!-- EN-Revision: 8a6397d39aefd23c61d64aa4e9af919772541e2a Maintainer: mowangjuanzi Status: ready -->
33
<sect1 xml:id="migration84.constants">
44
<title>新的全局常量</title>
55

@@ -284,6 +284,21 @@
284284
</simplelist>
285285
</sect2>
286286

287+
<sect2 xml:id="migration84.constants.tokenizer">
288+
<title>Tokenizer</title>
289+
<simplelist>
290+
<member>
291+
<constant>T_PUBLIC_SET</constant>
292+
</member>
293+
<member>
294+
<constant>T_PROTECTED_SET</constant>
295+
</member>
296+
<member>
297+
<constant>T_PRIVATE_SET</constant>
298+
</member>
299+
</simplelist>
300+
</sect2>
301+
287302
<sect2 xml:id="migration84.constants.xml">
288303
<title>XML</title>
289304

appendices/migration84/new-features.xml

Lines changed: 88 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<?xml version="1.0" encoding="utf-8"?>
2-
<!-- EN-Revision: 5fbf0f0cbce2dda6a379d8bda33d5b1869702e47 Maintainer: mowangjuanzi Status: partial -->
2+
<!-- EN-Revision: 8a9f4bd9d54a809d66f32d35ec60eb2b7353f76e Maintainer: mowangjuanzi Status: partial -->
33
<sect1 xml:id="migration84.new-features">
44
<title>新功能</title>
55

@@ -9,20 +9,48 @@
99

1010
<!-- RFC: https://wiki.php.net/rfc/property-hooks -->
1111
<sect3 xml:id="migration84.new-features.core.property-hooks">
12-
<title>属性钩子</title>
12+
<title>属性挂钩</title>
1313

1414
<simpara>
15-
TODO
15+
对象属性现在可以其 <literal>get</literal> 和 <literal>set</literal>
16+
操作中关联相关的附加逻辑。根据用法,这可能会也可能不会使属性变为虚拟属性,即该属性根本没有实际的存储值。
1617
</simpara>
1718

1819
<informalexample>
1920
<programlisting role="php">
2021
<![CDATA[
2122
<?php
22-
/*
23-
examples
24-
*/
23+
class Person
24+
{
25+
// “虚拟”属性,可能无法明确设置。
26+
public string $fullName {
27+
get => $this->firstName . ' ' . $this->lastName;
28+
}
29+
30+
// 所有的写入操作都会经过这个挂钩,结果就是写入的内容。
31+
// 读取访问正常。
32+
public string $firstName {
33+
set => ucfirst(strtolower($value));
34+
}
35+
36+
// 所有的写入操作都会经过这个挂钩,它必须写入支持值本身。
37+
// 读取访问正常。
38+
public string $lastName {
39+
set {
40+
if (strlen($value) < 2) {
41+
throw new \InvalidArgumentException('Too short');
42+
}
43+
$this->lastName = $value;
44+
}
45+
}
46+
}
47+
48+
$p = new Person();
2549
50+
$p->firstName = 'peter';
51+
print $p->firstName; // 打印“Peter”
52+
$p->lastName = 'Peterson';
53+
print $p->fullName; // 打印“Peter Peterson”
2654
]]>
2755
</programlisting>
2856
</informalexample>
@@ -42,6 +70,8 @@ examples
4270
<?php
4371
class Example
4472
{
73+
// 第一个可见性修饰符控制 get 可见性,第二个修饰符控制 set 可见性。
74+
// The get-visibility must not be narrower than set-visibility.
4575
public protected(set) string $name;
4676
4777
public function __construct(string $name)
@@ -56,19 +86,49 @@ class Example
5686

5787
<!-- RFC: https://wiki.php.net/rfc/lazy-objects -->
5888
<sect3 xml:id="migration84.new-features.core.lazy-objects">
59-
<title>Lazy Objects</title>
60-
89+
<title>惰性对象</title>
6190
<simpara>
62-
TODO
91+
现在可以创建对象,将初始化延迟到访问时。库和框架可以利用这些惰性对象来延迟获取初始化所需的数据或依赖项。
6392
</simpara>
93+
<informalexample>
94+
<programlisting role="php">
95+
<![CDATA[
96+
<?php
97+
class Example
98+
{
99+
public function __construct(private int $data)
100+
{
101+
}
102+
103+
// ...
104+
}
105+
106+
$initializer = static function (Example $ghost): void {
107+
// 获取数据或者依赖项
108+
$data = ...;
109+
// 初始化
110+
$ghost->__construct($data);
111+
};
112+
113+
$reflector = new ReflectionClass(Example::class);
114+
$object = $reflector->newLazyGhost($initializer);
115+
]]>
116+
</programlisting>
117+
</informalexample>
64118
</sect3>
65119

66120
<!-- RFC: https://wiki.php.net/rfc/deprecated_attribute -->
67121
<sect3 xml:id="migration84.new-features.core.deprecated-attribute">
68122
<title><code>#[\Deprecated]</code> 注解</title>
69123

70124
<simpara>
71-
TODO
125+
新的 <classname>Deprecated</classname> 属性可用于将函数、方法和类常量标记为已弃用。此弃用属性的行为与 PHP
126+
本身提供的现有弃用机制的行为一致。唯一的例外是发出的错误代码是 <constant>E_USER_DEPRECATED</constant>,而不是
127+
<constant>E_DEPRECATED</constant>。
128+
</simpara>
129+
130+
<simpara>
131+
PHP 本身提供的现有弃用已更新为使用该属性,通过包含简短的解释来改进发出的错误消息。
72132
</simpara>
73133
</sect3>
74134

@@ -190,9 +250,16 @@ class Example
190250
<sect2 xml:id="migration84.new-features.dom">
191251
<title>DOM</title>
192252

253+
<!-- RFC: https://wiki.php.net/rfc/domdocument_html5_parser -->
254+
<!-- RFC: https://wiki.php.net/rfc/opt_in_dom_spec_compliance -->
255+
<simpara>
256+
添加了 <package>Dom</package> 命名空间,其中包含与现有 DOM 类对应的新类(例如,<classname>Dom\Node</classname> 是新的
257+
<classname>DOMNode</classname>)。这些类与 HTML 5 兼容,并且符合 WHATWG 规范;解决了 DOM 扩展中长期存在的错误。旧的 DOM
258+
类仍然可用,以实现向后兼容。
259+
</simpara>
260+
193261
<para>
194-
Added the <methodname>DOMNode::compareDocumentPosition</methodname>
195-
with its associated constants:
262+
新增 <methodname>DOMNode::compareDocumentPosition</methodname> 及其相关常量:
196263
<simplelist>
197264
<member><constant>DOMNode::DOCUMENT_POSITION_DISCONNECTED</constant></member>
198265
<member><constant>DOMNode::DOCUMENT_POSITION_PRECEDING</constant></member>
@@ -205,23 +272,11 @@ class Example
205272

206273
<!-- RFC: https://wiki.php.net/rfc/improve_callbacks_dom_and_xsl -->
207274
<simpara>
208-
It is now possible to pass any callable to
209-
<methodname>DOMXPath::registerPhpFunctions</methodname>.
210-
<!-- TODO Mention DOMXPath::registerPHPFunctionNS ? -->
211-
</simpara>
212-
</sect2>
275+
现在可以将任何 callable 传递给
276+
<methodname>DOMXPath::registerPhpFunctions</methodname>。
213277

214-
<!-- TODO: Should this be moved to "other changes" in the SAPI section? - Girgias -->
215-
<sect2 xml:id="migration84.new-features.fpm">
216-
<title>FPM</title>
217-
218-
<simpara>
219-
Flushing headers without a body will now succeed.
220-
<!-- See GH-12785. -->
221-
</simpara>
222-
223-
<simpara>
224-
状态页面新增字段用于展示内存峰值。
278+
此外,现在使用 <methodname>DOMXPath::registerPhpFunctionNs</methodname> 可以注册使用原生函数调用语法,而不是使用
279+
<code>php:function('name')</code>。
225280
</simpara>
226281
</sect2>
227282

@@ -391,8 +446,8 @@ class Example
391446
</simpara>
392447
</sect2>
393448

394-
<sect2 xml:id="migration84.new-features.reflection">
395-
<title>Reflection</title>
449+
<sect2 xml:id="migration84.new-features.readline">
450+
<title>Readline</title>
396451

397452
<simpara>
398453
<classname>ReflectionAttribute</classname> now contains a
@@ -407,9 +462,7 @@ class Example
407462

408463
<!-- RFC: https://wiki.php.net/rfc/lazy-objects -->
409464
<para>
410-
Multiple new methods and constants which are related to the lazy objects
411-
feature have been added:
412-
465+
添加了与惰性对象功能相关的多个新方法和常量:
413466
<simplelist>
414467
<member>
415468
<methodname>ReflectionClass::newLazyGhost</methodname>
@@ -436,10 +489,10 @@ class Example
436489
<methodname>ReflectionClass::getLazyInitializer</methodname>
437490
</member>
438491
<member>
439-
<methodname>ReflectionClass::skipLazyInitialization</methodname>
492+
<methodname>ReflectionProperty::skipLazyInitialization</methodname>
440493
</member>
441494
<member>
442-
<methodname>ReflectionClass::setRawValueWithoutLazyInitialization</methodname>
495+
<methodname>ReflectionProperty::setRawValueWithoutLazyInitialization</methodname>
443496
</member>
444497
<member>
445498
<constant>ReflectionClass::SKIP_INITIALIZATION_ON_SERIALIZE</constant>

appendices/migration84/new-functions.xml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<?xml version="1.0" encoding="utf-8"?>
2-
<!-- EN-Revision: d64e811eac61a5c7c744312d8bc6e2244de81488 Maintainer: mowangjuanzi Status: ready -->
2+
<!-- EN-Revision: b719f01467440fa9cfb52b09a1fc8b832ccb5d18 Maintainer: mowangjuanzi Status: ready -->
33
<sect1 xml:id="migration84.new-functions">
44
<title>新函数</title>
55

@@ -184,10 +184,10 @@
184184
<methodname>ReflectionClass::getLazyInitializer</methodname>
185185
</member>
186186
<member>
187-
<methodname>ReflectionClass::skipLazyInitialization</methodname>
187+
<methodname>ReflectionProperty::skipLazyInitialization</methodname>
188188
</member>
189189
<member>
190-
<methodname>ReflectionClass::setRawValueWithoutLazyInitialization</methodname>
190+
<methodname>ReflectionProperty::setRawValueWithoutLazyInitialization</methodname>
191191
</member>
192192
</simplelist>
193193
</para>

0 commit comments

Comments
 (0)